Thursday, April 14, 2011

How to Retrieve XML Node Attributes In C#

Hi

how to navigate the XML file and get all a list of nodes in order to access their attributes and count no of nodes in Student tag.

for example :

Can anybody briefy me .how to do ? give any sample code to do so.?

Thanks & Regards

Ravi Kumar

From stackoverflow
  • You can get a collection of XmlNodes from and XmlDocument like this

    XmlNodeList nodes = document.GetElementsByTagName("MyNodeName");
    foreach (XmlNode node in nodes)
    {
        // do stuff with each node
    }
    

    The XmlNode class has an Attributes property which is a collection of attributes. You can iterate through them and match the attributes you are looking for.

0 comments:

Post a Comment