locked
From XML to Sharepoint? RRS feed

  • Question

  • Hello,

    As I have understood there are many ways to get the topic question done. So if i have mutiple XML files that are connected too eighother by urls. For example:

    messages

       message-name

       message-url

       message-image

    So if the above is the case is it best to be using PowerShell or C#? Eventually I need an object with the properties as above written. With this object I need to fill a list within a SharePoint project.

    Some tips would be need.

    Greetings,

    SpaceLama

    Thursday, April 12, 2012 8:10 PM

Answers

  • Hi SpaceLama,

    First, you should use C# to read your XML file, then you can get the XML nodes or properties. You can put these nodes and properties in to your custom class. After this, you can use object module to do it.

    <Names>
        <Name>
            <FirstName>Jack</FirstName>
            <LastName>Green</LastName>
        </Name>
    </Names>

    XmlDocument xml = new XmlDocument();
    xml.LoadXml(myXmlString); // suppose that myXmlString contains "<Names>...</Names>"
    XmlNodeList xnList = xml.SelectNodes("/Names/Name");
    foreach (XmlNode xn in xnList)
    {
      string firstName = xn["FirstName"].InnerText;
      string lastName = xn["LastName"].InnerText;
     // you can create a custom class withe these properties 
    }

    Thanks,

    Jack



    Thursday, April 19, 2012 2:00 AM
    Moderator