none
How to load xml document content from a SP list/library?

    שאלה

  • I have a form list/library in SharePoint, which consists of InfoPath forms, they are all in xml format.

    Now, I need to go through all the xml files and retrieve some of its content. But I have no idea what code I have to write in order to get the xml document loaded onto. I have something like this, what should I do in the bolded section below?

    PList formLibrary =   newSite.AllWebs[strServerURL].Lists[libraryName];
    SPListItemCollection collListItems = formLibrary.Items;
    foreach (SPListItem oListItem in collListItems)
    {
        {
    ??? what should I do here ??? Where formXML will be the text of the file.

      XmlDocument doc = new XmlDocument();
                            doc.InnerXml = formXML;
                            XmlNamespaceManager xNameSpace = InitNamespaceManager(doc);
                            XPathNavigator xNavMain = doc.CreateNavigator();

    Thanks in advance, your help would be greatly appreciated.

    יום שלישי 01 מאי 2012 20:23

תשובות

  • I was able to get this working with the following code.

    Stream fStream = oListItem.File.OpenBinaryStream() ;

    byte[] MyData = new byte[fStream.Length];
    fStream.Read(MyData, 0, (int)fStream.Length);
    string formXML = Encoding.Unicode.GetString(MyData);
    formXML = Encoding.UTF8.GetString(MyData);

    • סומן כתשובה על-ידי wkpli יום רביעי 02 מאי 2012 13:50
    יום רביעי 02 מאי 2012 13:50

כל התגובות