I have created an xml file like below
<Engagements>
<User name ="jjjj">
<Engagement id="1111"/>
</User>
<User name ="kkkk">
<Engagement id="2222"/>
</User>
</Engagements>
I need to get all the id values from all of the Engagement nodes.
This is what I currently have:
public static void ParseXml(XmlDocument xmlFile)
{
XmlNodeList nodes = xmlFile.SelectNodes("//Engagement");
foreach (XmlNode node in nodes)
{
// What goes here?
}
}
Use LINQ to XML: