title: How to parse Inner-XML return from SharePoint Web Services
body: <p>I have a program as such</p>
  
  <pre><code>    // establish proxy obj
      SPLists.Lists listservice = new SPLists.Lists();
  
      // credentials
      listservice.PreAuthenticate = true;
  
  
      // user name
      Console.Write("Username (e.g. bobdole@xyz.com): ");
      string usrname = Console.ReadLine().Trim();
      Console.Write("\n");
  
      // pw
      Console.Write("Password: ");
      string password = MaskedConsoleReader.ReadLine();
  
      // auth
      listservice.Credentials = new NetworkCredential(usrname, password);
  
      // List Service URL
      listservice.Url =
        "https://wss.xyz.com/_vti_bin/Lists.asmx";
  
      // Instantiate an XmlDocument object 
      System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
  
  
      /* Assign values to the string parameters of the GetListItems method, 
      using GUIDs for the listName and viewName variables. For listName, 
      using the list display name will also work, but using the list GUID 
      is recommended. For viewName, only the view GUID can be used. 
      Using an empty string for viewName causes the default view to be used.*/
      // Work ticket list
      // {5B79ED7D-ECB7-447A-9331-22984E52EB7D}
      // All tickets view
      // {00F95DDD-C383-4E4A-94F2-977FDA7A7F74}
  
      string listName = "{5B79ED7D-ECB7-447A-9331-22984E52EB7D}";
      string viewName = "{00F95DDD-C383-4E4A-94F2-977FDA7A7F74}";
      string rowLimit = "4000";
  
      /*Use the CreateElement method of the document object to create 
      elements for the parameters that use XML.*/
      System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
      System.Xml.XmlElement viewFields =
          xmlDoc.CreateElement("ViewFields");
      System.Xml.XmlElement queryOptions =
          xmlDoc.CreateElement("QueryOptions");
  
      /*To specify values for the parameter elements (optional), assign 
      CAML fragments to the InnerXml property of each element.*/
      query.InnerXml = "&lt;Where&gt;&lt;Gt&gt;&lt;FieldRef Name=\"ID\" /&gt;" +
          "&lt;Value Type=\"Counter\"&gt;3&lt;/Value&gt;&lt;/Gt&gt;&lt;/Where&gt;";
      viewFields.InnerXml = "&lt;FieldRef Name=\"Title\" /&gt;";
      queryOptions.InnerXml = "";
  
      /* Declare an XmlNode object and initialize it with the XML response 
      from the GetListItems method. The last parameter specifies the GUID 
      of the Web site containing the list. Setting it to null causes the 
      Web site specified by the Url property to be used.*/
  
      DateTime abc = DateTime.Now;
      string format = "yyyy-M-dd_HH-MM-ss";
      string xyz = abc.ToString(format);
      string fName = "dump-" + xyz + ".txt";
  
      try
      {
  
          System.Xml.XmlNode nodeListItems =
              listservice.GetListItems
              (listName, viewName, query, viewFields, rowLimit, queryOptions, null);
  
          StreamWriter outfile = new StreamWriter(fName);
  
  
          /*Loop through each node in the XML response and display each item.*/
          foreach (System.Xml.XmlNode listItem in nodeListItems)
          {
              Console.WriteLine(listItem.OuterXml + "\n");
              outfile.WriteLine(listItem.OuterXml);
  
          }
          outfile.Close();
  
  
      }
      catch (Exception ex)
      {
          Console.WriteLine("ERROR!: " + ex.ToString());
      }
  
      Console.WriteLine("\n");
      Console.WriteLine("Contents dumped to: " + fName);
  
      // hold program
      Console.ReadLine();
  
  }
  </code></pre>
  
  <p>Which yields a string (from listItem.OuterXML):</p>
  
  <pre><code>&lt;rs:data ItemCount="896" xmlns:rs="urn:schemas-microsoft-com:rowset"&gt;
  [...]
  &lt;z:row ows_Title="Do A B AND C" ows_ProjectID="1165;#_INTERNAL" ows__ModerationStatus="0" ows__Level="1" ows_Deliverables="&amp;lt;div&amp;gt;Implementation of blah blah blah" ows_AssignedTo="7;#blah@xyz.com" ows_ID="5" ows_owshiddenversion="29" ows_UniqueId="5;#{DD129C47-C9E0-4962-A516-B8280EB77800}" ows_FSObjType="5;#0" ows_Created="2009-02-27 08:25:28" ows_Category="7 Internal Project" ows_Comment="&amp;lt;div&amp;gt;Changing to Queue of 22 blah can do blah" ows_Priority="4 Low" ows_Status="1 In Queue" ows_Description_x0020_of_x0020_Work="do blah and blah" ows_FileRef="5;#Lists/Work Tick/5_.000" ows_ProjectOwner="7;#blah@xyz.com" ows_MetaInfo="5;#" xmlns:z="#RowsetSchema" /&gt;
  [...]
  &lt;/rs:data&gt;
  </code></pre>
  
  <p>There are roughly 800 lines like this in the returned string. What's the easiest way to parse the data from each line? I'd also like to strip out the HTML if possible since I want to eventually dump this into SQL server using the SQLClient namespace.</p>