I have an xml file and need to extract the InnerXML from a second level child node using C#. Below is a snippet of my XML.
<joblisting:department>Supply</joblisting:department>
<guid isPermaLink="true">https://www.governmentjobs.com/careers/ocso/Jobs/2594527</guid>
<joblisting:categories>
<joblisting:category xmlns:joblisting="http://www.neogov.com/namespaces/JobListing" xmlns:atom="http://www.w3.org/2005/Atom">
<CategoryCode>ClericalDataEntry</CategoryCode>
<Category>Clerical & Data Entry</Category>
</joblisting:category>
</joblisting:categories>
I need to get the value of the Category element.
I tried using this C# code:
XmlNode t = rssNode.LastChild;
if (t.HasChildNodes)
{
for (int i = 0; i < t.ChildNodes.Count; i++)
{
string xcategory = (t.ChildNodes[i].InnerXml);
string category = "<category>" + xcategory + "</category>";
sb.AppendLine(category);
}
}
but it returns the entire child tree as
<category>
<CategoryCode>ClericalDataEntry</CategoryCode>
<Category>Clerical & Data Entry</Category>
</category
All I want to get is is the value from the Category element
How can I drill down to that element only?