title: How to read the XML response from SharePoint REST api call
body: <p>I am getting XML response for REST call which includes multiple <em>subnodes</em> for each entry. Basically any <code>Lookup</code> field or <code>User</code> field results in a <em>subnode</em>. 
  Can anybody help me to understand how to read these <em>subnodes</em>? As the element name is <code>Id</code> or <code>Email</code> which is repetitive. Sorry for the very long XML but this is a result of fetching only 2 items. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;feed xml:base="https://ppespcollab.amat.com/sites/SSAS/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"&gt;
      &lt;id&gt;f7f3e0d8-73aa-4bd9-a11c-c8d2c884895c&lt;/id&gt;
      &lt;title /&gt;
      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
      &lt;entry m:etag="&amp;quot;5&amp;quot;"&gt;
          &lt;id&gt;Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)&lt;/id&gt;
          &lt;category term="SP.Data.RequestsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
          &lt;link rel="edit" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)" /&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Name" type="application/atom+xml;type=entry" title="Name" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)/Name"&gt;
              &lt;m:inline&gt;
                  &lt;entry&gt;
                      &lt;id&gt;d724a6a3-c532-4f43-baaf-f3a25bbaccca&lt;/id&gt;
                      &lt;category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;author&gt;
                          &lt;name /&gt;
                      &lt;/author&gt;
                      &lt;content type="application/xml"&gt;
                          &lt;m:properties&gt;
                              &lt;d:Id m:type="Edm.Int32"&gt;31210&lt;/d:Id&gt;
                              &lt;d:EMail&gt;Ishan_Halarnkar@contractor.amat.com&lt;/d:EMail&gt;
                          &lt;/m:properties&gt;
                      &lt;/content&gt;
                  &lt;/entry&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Segment" type="application/atom+xml;type=entry" title="Segment" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)/Segment"&gt;
              &lt;m:inline&gt;
                  &lt;entry&gt;
                      &lt;id&gt;9d4306ec-4b01-4624-984b-79445b9d2ec1&lt;/id&gt;
                      &lt;category term="SP.Data.SegmentsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;author&gt;
                          &lt;name /&gt;
                      &lt;/author&gt;
                      &lt;content type="application/xml"&gt;
                          &lt;m:properties&gt;
                              &lt;d:Title&gt;Test - TechM&lt;/d:Title&gt;
                              &lt;d:Id m:type="Edm.Int32"&gt;10&lt;/d:Id&gt;
                          &lt;/m:properties&gt;
                      &lt;/content&gt;
                  &lt;/entry&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/BU" type="application/atom+xml;type=feed" title="BU" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)/BU"&gt;
              &lt;m:inline&gt;
                  &lt;feed&gt;
                      &lt;id&gt;7d3cf6e4-9fdc-4c21-90e9-5112b963dc49&lt;/id&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;entry&gt;
                          &lt;id&gt;44c3ff84-4650-4d85-a6dc-908639338be4&lt;/id&gt;
                          &lt;category term="SP.Data.Business_x0020_UnitsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                          &lt;title /&gt;
                          &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                          &lt;author&gt;
                              &lt;name /&gt;
                          &lt;/author&gt;
                          &lt;content type="application/xml"&gt;
                              &lt;m:properties&gt;
                                  &lt;d:Title&gt;CMP&lt;/d:Title&gt;
                                  &lt;d:Id m:type="Edm.Int32"&gt;14&lt;/d:Id&gt;
                              &lt;/m:properties&gt;
                          &lt;/content&gt;
                      &lt;/entry&gt;
                  &lt;/feed&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author0" type="application/atom+xml;type=feed" title="Author0" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)/Author0"&gt;
              &lt;m:inline&gt;
                  &lt;feed&gt;
                      &lt;id&gt;0f399745-10f4-40f0-be4e-1f9d69222d49&lt;/id&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;entry&gt;
                          &lt;id&gt;4c0509ce-62c4-4e90-9689-134b145b02a0&lt;/id&gt;
                          &lt;category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                          &lt;title /&gt;
                          &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                          &lt;author&gt;
                              &lt;name /&gt;
                          &lt;/author&gt;
                          &lt;content type="application/xml"&gt;
                              &lt;m:properties&gt;
                                  &lt;d:Id m:type="Edm.Int32"&gt;31210&lt;/d:Id&gt;
                                  &lt;d:EMail&gt;Ishan_Halarnkar@contractor.amat.com&lt;/d:EMail&gt;
                              &lt;/m:properties&gt;
                          &lt;/content&gt;
                      &lt;/entry&gt;
                  &lt;/feed&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CC_x0020_List" type="application/atom+xml;type=feed" title="CC_x0020_List" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)/CC_x0020_List" /&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Publication_x0020_Type" type="application/atom+xml;type=entry" title="Publication_x0020_Type" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(160)/Publication_x0020_Type"&gt;
              &lt;m:inline&gt;
                  &lt;entry&gt;
                      &lt;id&gt;a002d855-e51b-4f4f-b8ec-3725cf4aecb9&lt;/id&gt;
                      &lt;category term="SP.Data.Publication_x0020_TypeListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;author&gt;
                          &lt;name /&gt;
                      &lt;/author&gt;
                      &lt;content type="application/xml"&gt;
                          &lt;m:properties&gt;
                              &lt;d:Title&gt;Presentation&lt;/d:Title&gt;
                              &lt;d:Id m:type="Edm.Int32"&gt;2&lt;/d:Id&gt;
                          &lt;/m:properties&gt;
                      &lt;/content&gt;
                  &lt;/entry&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;title /&gt;
          &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
          &lt;author&gt;
              &lt;name /&gt;
          &lt;/author&gt;
          &lt;content type="application/xml"&gt;
              &lt;m:properties&gt;
                  &lt;d:Id m:type="Edm.Int32"&gt;160&lt;/d:Id&gt;
                  &lt;d:Title&gt;asssfsfdsf&lt;/d:Title&gt;
                  &lt;d:End_x0020_Use&gt;BLR&lt;/d:End_x0020_Use&gt;
                  &lt;d:Approval_x0020_Type&gt;Parallel&lt;/d:Approval_x0020_Type&gt;
                  &lt;d:Due_x0020_Date m:type="Edm.DateTime"&gt;2017-09-26T05:00:00Z&lt;/d:Due_x0020_Date&gt;
                  &lt;d:Description&gt;sdfssfsfssf&lt;/d:Description&gt;
                  &lt;d:Status&gt;Submitted&lt;/d:Status&gt;
                  &lt;d:History&gt;Request submitted by Ishan Halarnkar --CNTR on Wednesday, September 13, 2017 8&amp;amp;#58;15 AM&amp;lt;/br&amp;gt;&lt;/d:History&gt;
                  &lt;d:RequestID&gt;2017_00000160&lt;/d:RequestID&gt;
                  &lt;d:EndUseYear&gt;2014&lt;/d:EndUseYear&gt;
                  &lt;d:ID m:type="Edm.Int32"&gt;160&lt;/d:ID&gt;
              &lt;/m:properties&gt;
          &lt;/content&gt;
      &lt;/entry&gt;
      &lt;entry m:etag="&amp;quot;7&amp;quot;"&gt;
          &lt;id&gt;Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)&lt;/id&gt;
          &lt;category term="SP.Data.RequestsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
          &lt;link rel="edit" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)" /&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Name" type="application/atom+xml;type=entry" title="Name" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)/Name"&gt;
              &lt;m:inline&gt;
                  &lt;entry&gt;
                      &lt;id&gt;b76cc22b-f985-444a-873a-46ae2cd0a10a&lt;/id&gt;
                      &lt;category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;author&gt;
                          &lt;name /&gt;
                      &lt;/author&gt;
                      &lt;content type="application/xml"&gt;
                          &lt;m:properties&gt;
                              &lt;d:Id m:type="Edm.Int32"&gt;6760&lt;/d:Id&gt;
                              &lt;d:EMail&gt;Denise_Schmidt@amat.com&lt;/d:EMail&gt;
                          &lt;/m:properties&gt;
                      &lt;/content&gt;
                  &lt;/entry&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Segment" type="application/atom+xml;type=entry" title="Segment" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)/Segment"&gt;
              &lt;m:inline&gt;
                  &lt;entry&gt;
                      &lt;id&gt;6e70b80b-fff6-4662-8f53-26fc977f34ef&lt;/id&gt;
                      &lt;category term="SP.Data.SegmentsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;author&gt;
                          &lt;name /&gt;
                      &lt;/author&gt;
                      &lt;content type="application/xml"&gt;
                          &lt;m:properties&gt;
                              &lt;d:Title&gt;Testing Segment 0917&lt;/d:Title&gt;
                              &lt;d:Id m:type="Edm.Int32"&gt;11&lt;/d:Id&gt;
                          &lt;/m:properties&gt;
                      &lt;/content&gt;
                  &lt;/entry&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/BU" type="application/atom+xml;type=feed" title="BU" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)/BU"&gt;
              &lt;m:inline&gt;
                  &lt;feed&gt;
                      &lt;id&gt;f5e5e76d-07b7-442f-b6bf-73d9ed65e708&lt;/id&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;entry&gt;
                          &lt;id&gt;07bd9eed-23f7-4b10-8f38-42e0845f19ca&lt;/id&gt;
                          &lt;category term="SP.Data.Business_x0020_UnitsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                          &lt;title /&gt;
                          &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                          &lt;author&gt;
                              &lt;name /&gt;
                          &lt;/author&gt;
                          &lt;content type="application/xml"&gt;
                              &lt;m:properties&gt;
                                  &lt;d:Title&gt;ds Testing&lt;/d:Title&gt;
                                  &lt;d:Id m:type="Edm.Int32"&gt;24&lt;/d:Id&gt;
                              &lt;/m:properties&gt;
                          &lt;/content&gt;
                      &lt;/entry&gt;
                  &lt;/feed&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author0" type="application/atom+xml;type=feed" title="Author0" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)/Author0"&gt;
              &lt;m:inline&gt;
                  &lt;feed&gt;
                      &lt;id&gt;717cf9a2-9f0a-4265-bb32-1c90989ba6ed&lt;/id&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;entry&gt;
                          &lt;id&gt;4c593a4e-5c2e-4f1a-8c99-cb2d81b33af3&lt;/id&gt;
                          &lt;category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                          &lt;title /&gt;
                          &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                          &lt;author&gt;
                              &lt;name /&gt;
                          &lt;/author&gt;
                          &lt;content type="application/xml"&gt;
                              &lt;m:properties&gt;
                                  &lt;d:Id m:type="Edm.Int32"&gt;6760&lt;/d:Id&gt;
                                  &lt;d:EMail&gt;Denise_Schmidt@amat.com&lt;/d:EMail&gt;
                              &lt;/m:properties&gt;
                          &lt;/content&gt;
                      &lt;/entry&gt;
                  &lt;/feed&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CC_x0020_List" type="application/atom+xml;type=feed" title="CC_x0020_List" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)/CC_x0020_List" /&gt;
          &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Publication_x0020_Type" type="application/atom+xml;type=entry" title="Publication_x0020_Type" href="Web/Lists(guid'16b26978-b5d8-407a-a82d-e66017158895')/Items(159)/Publication_x0020_Type"&gt;
              &lt;m:inline&gt;
                  &lt;entry&gt;
                      &lt;id&gt;62f94289-1e4b-4e83-94fe-1f518bde639b&lt;/id&gt;
                      &lt;category term="SP.Data.Publication_x0020_TypeListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
                      &lt;title /&gt;
                      &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
                      &lt;author&gt;
                          &lt;name /&gt;
                      &lt;/author&gt;
                      &lt;content type="application/xml"&gt;
                          &lt;m:properties&gt;
                              &lt;d:Title&gt;Presentation&lt;/d:Title&gt;
                              &lt;d:Id m:type="Edm.Int32"&gt;2&lt;/d:Id&gt;
                          &lt;/m:properties&gt;
                      &lt;/content&gt;
                  &lt;/entry&gt;
              &lt;/m:inline&gt;
          &lt;/link&gt;
          &lt;title /&gt;
          &lt;updated&gt;2017-09-14T09:51:55Z&lt;/updated&gt;
          &lt;author&gt;
              &lt;name /&gt;
          &lt;/author&gt;
          &lt;content type="application/xml"&gt;
              &lt;m:properties&gt;
                  &lt;d:Id m:type="Edm.Int32"&gt;159&lt;/d:Id&gt;
                  &lt;d:Title&gt;Test on 9/12/17&lt;/d:Title&gt;
                  &lt;d:End_x0020_Use&gt;TPAS&lt;/d:End_x0020_Use&gt;
                  &lt;d:Approval_x0020_Type&gt;Parallel&lt;/d:Approval_x0020_Type&gt;
                  &lt;d:Due_x0020_Date m:type="Edm.DateTime"&gt;2017-09-28T05:00:00Z&lt;/d:Due_x0020_Date&gt;
                  &lt;d:Description&gt;testing email notices&lt;/d:Description&gt;
                  &lt;d:Status&gt;Submitted&lt;/d:Status&gt;
                  &lt;d:History&gt;Request delegated by Denise Schmidt (ds Testing - CTO) on Tuesday, September 12, 2017 2&amp;amp;#58;16 PM&amp;lt;/br&amp;gt;Request approved by Denise Schmidt (ds Testing - Manager) on Tuesday, September 12, 2017 2&amp;amp;#58;15 PM&amp;lt;/br&amp;gt;Request submitted by Denise Schmidt on Tuesday, September 12, 2017 2&amp;amp;#58;12 PM&amp;lt;/br&amp;gt;&lt;/d:History&gt;
                  &lt;d:RequestID&gt;2017_00000159&lt;/d:RequestID&gt;
                  &lt;d:EndUseYear m:null="true" /&gt;
                  &lt;d:ID m:type="Edm.Int32"&gt;159&lt;/d:ID&gt;
              &lt;/m:properties&gt;
          &lt;/content&gt;
      &lt;/entry&gt;
  </code></pre>
  
  <p></p>
  
  <p>The code i am using is but is not giving the expected results :</p>
  
  <pre><code>XmlDocument listXml = new XmlDocument();
              XmlNamespaceManager xmlnspm = new XmlNamespaceManager(new NameTable());
              xmlnspm.AddNamespace("atom", "http://www.w3.org/2005/Atom");
              xmlnspm.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
              xmlnspm.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
              listXml.LoadXml(response);
              var prop = listXml.SelectNodes("//atom:entry/atom:content/m:properties", xmlnspm);
              List&lt;string&gt; sdsd = new List&lt;string&gt;();
              foreach (XmlNode ndlist in prop)
  
              {
  
                  sdsd.Add(ndlist.SelectSingleNode("d:Id", xmlnspm).InnerXml +
                      ndlist.SelectSingleNode("d:EMail", xmlnspm).InnerXml +
                       ndlist.SelectSingleNode("d:Status", xmlnspm).InnerXml+
                       ndlist.SelectSingleNode("d:History", xmlnspm).InnerXml);
              }
  </code></pre>
  
  <p>The result i am looking for is :
  For each entry, read the </p>
  
  <ol>
  <li>If Name then Name(Id and Email)</li>
  <li>If Segment then Segment(Title and Id)</li>
  <li>If BU then BU(Title and Id)</li>
  <li>If Author0 then Author0(Id and Email)
  ...likewise for all subnodes
  and for all main nodes i need the value</li>
  <li>Id</li>
  <li>Title</li>
  <li>End_x0020_Use</li>
  <li>Approval_x0020_Type</li>
  </ol>
  
  <p>Is there any way to Serialize this data in a more readable format or i'l have to loop each and every node?
  Please suggest the best option as i don't have much experience in XML data.</p>