locked
XML Schema Enumeration RRS feed

  • Question

  • I have code in VB, which allowed me to query a SharePoint List Service and return ether the Schema (OuterXML) or the Data (InnerXML).  I'm trying to expand on the functionality of that app as well as learn C#.  I've discovered that the XMLNode.OuterXML in C# does not contain the Schema information.  In fact, the only difference I can determine about these two methods is that the OuterXML contains the <listitems> elements.

    Any insight is greatly appreciated.

    using System;  
    using System.AddIn;  
    using System.Data;  
    using System.Data.SqlClient;  
    using System.Windows.Forms;  
    using System.Xml;  
    using SharePointServices;  
    using SharePointServices.NorthwindSync;  
    using System.IO;  
    using System.Net;  
    using System.Web;  
     
    namespace SharePoint_LIst_Retrieval  
    {  
        [System.AddIn.AddIn("Program", Version = "1.0", Publisher = "me", Description = "A simple script to export multiple SharePoint Lists to an XML file.")]  
          
        class Program  
        {  
            static void Main()  
            {  
                String conxString = "Data Source=MyServer; Integrated Security=True;", DocLoc,  
                    listName, xmlFile;  
                SqlDataAdapter oleda = new SqlDataAdapter();  
                DataTable tblItems = new DataTable();  
                Lists listService = new Lists();  
                XmlNode node;  
                TextWriter TextDoc;  
     
                listService.Credentials = CredentialCache.DefaultNetworkCredentials;  
     
                using (SqlConnection sqlConx = new SqlConnection(conxString))  
                {  
                    SqlCommand txtCommand = new SqlCommand("SELECT * FROM MyDB.dbo.SharePointLists", sqlConx);  
     
                    sqlConx.Open();  
                    oleda.SelectCommand = txtCommand;  
                    oleda.Fill(tblItems);  
                    sqlConx.Close();  
                }  
     
                foreach (DataRow row in tblItems.Rows)  
                {  
                    listService.Url = row["SharePoint_Url"].ToString();  
                    listName = row["List_Name"].ToString();  
                    DocLoc = row["File_Path"].ToString() + row["File_Name"].ToString() + ".xml";  
     
                    node = ListHelper.GetAllListItems(listService, listName);  
     
                    xmlFile = node.OuterXml;  
     
                    TextDoc = File.CreateText(DocLoc);  
                    TextDoc.WriteLine(xmlFile);  
                    TextDoc.Flush();  
                    TextDoc.Close();  
     
                    MessageBox.Show("File created:  " + DocLoc, "List File Created", MessageBoxButtons.OK);  
     
                    DocLoc = row["File_Path"].ToString() + row["File_Name"].ToString() + ".xsd";  
     
                    xmlFile = node.;  <---problem line
     
                    TextDoc = File.CreateText(DocLoc);  
                    TextDoc.WriteLine(xmlFile);  
                    TextDoc.Flush();  
                    TextDoc.Close();  
     
                    MessageBox.Show("File created:  " + DocLoc, "XSD File Created", MessageBoxButtons.OK);  
                }  
            }  
        }  
    • Edited by Chris Fo Friday, June 6, 2008 7:03 PM forgot to remove my alias
    • Moved by jack 321 Wednesday, June 11, 2008 3:37 AM off topic for C# general
    Friday, June 6, 2008 7:02 PM

Answers