title: C# XMLNodeList Item Children
body: <p>I'm currently working on importing XML feed data into our CMS, but am struggling in how to tackle this issue.</p>
  
  <p>For a course, it can have up to 9 staff members looking after it. Each having a name, phone number, email address and type of job. In the CMS for the import, i have 9 sets of these 4 fields, in order to save the data. To get around this, if there is only 5 staff out of 9, i'm targeting an XMLnodelist of course contacts - if it's null, have an empty string, otherwise populate fields.</p>
  
  <p>In the code below, cclist is defined as an xmlnodelist, and test1 gets the full contents of International Admissions as a whole as a string.</p>
  
  <p>What i want to be able to do, using the same format expanded, is for up to 9 course contacts, get the name, email, phone etc of the xmlnodelist item and separate them out, so they can be targeted for the import. I've tried using descendants etc, but can't seem to be able to target these individually, instead of a full string.</p>
  
  <p>Any help would be greatly appreciated. Thanks.</p>
  
  <p><strong>XML</strong></p>
  
  <pre><code>&lt;course&gt;
      &lt;dc:description&gt;...&lt;/dc:description&gt;
      &lt;dc:title&gt;
          &lt;![CDATA[ Marketing ]]&gt;
      &lt;/dc:title&gt;
      &lt;learningOutcome&gt;...&lt;/learningOutcome&gt;
      &lt;test:coursecontacts
          &lt;test:contact xsi:type="LeadAcademic"&gt;
              &lt;test:name
                  &lt;![CDATA[ Tommy Thompson ]]&gt;
              &lt;/test:name
              &lt;test:phone&gt;0123456789&lt;/test:phone&gt;
              &lt;test:email&gt;tt@test.com&lt;/test:email&gt;
          &lt;/test:contact&gt;
          &lt;test:contact xsi:type="Admissions Administrator"&gt;
              &lt;test:name&gt;
                  &lt;![CDATA[ International Admissions ]]&gt;
              &lt;/test:name&gt;
              &lt;test:phone&gt;0123456678&lt;/test:phone&gt;
              &lt;test:email&gt;ia@test.com&lt;/test:email
          &lt;/test:contact
          &lt;test:contact xsi:type="Course Leader"&gt;...&lt;/test:contact&gt;
          &lt;test:contact xsi:type="Admissions Administrator"&gt;...&lt;/test:contact&gt;
          &lt;test:contact xsi:type="Course Administrator"&gt;...&lt;/test:contact&gt;
      &lt;/test:coursecontacts&gt;
  &lt;/course&gt;
  </code></pre>
  
  <p><strong>C#</strong></p>
  
  <pre><code>protected override FeedCourse MapXmlNodeToEntity(XElement p)
          {
              var xmlResult = new XmlDocument();
              xmlResult.LoadXml(p.ToString());
              var test = p.ToString();
  
              var xmlnsManager = new XmlNamespaceManager(xmlResult.NameTable);
              xmlnsManager.AddNamespace("ns", "http://xcri.org/profiles/1.2/catalog");
              xmlnsManager.AddNamespace("xcriTerms", "http://xcri.org/profiles/catalog/terms");
              xmlnsManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
              xmlnsManager.AddNamespace("xhtml", "http://www.w3.org/1999/xhtml");
              xmlnsManager.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
              xmlnsManager.AddNamespace("dcterms", "http://purl.org/dc/terms/");
              xmlnsManager.AddNamespace("credit", "http://purl.org/net/cm");
              xmlnsManager.AddNamespace("mlo", "http://purl.org/net/mlo");
              xmlnsManager.AddNamespace("courseDataProgramme", "http://xcri.co.uk");
              xmlnsManager.AddNamespace("test", "http://www.test.com");
  
              var elements = xmlResult.ChildNodes;
  
              var title = xmlResult.DocumentElement.SelectSingleNode("dc:title", xmlnsManager).InnerText;
              var description = xmlResult.DocumentElement.SelectSingleNode("dc:description", xmlnsManager).InnerText;
              var learningOutcome = xmlResult.DocumentElement.SelectSingleNode("ns:learningOutcome", xmlnsManager).InnerText;
  
  
              XmlNodeList ccList = xmlResult.DocumentElement.SelectNodes("test:coursecontacts/test:contact", xmlnsManager);
              var test1 = ccList.Item(1).InnerText;
  </code></pre>
  
  <p>// Above line gets full contents of test:contact, but i need down to levels of xsi:type, name, phone and email</p>
  
  <pre><code>        }
  </code></pre>