• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Parse XML file

I have a task like

sent xml file to a method() and parse the xml file inside the method to get the tag value for further process how can i do that in c#?
0
Rahamathulla_J
Asked:
Rahamathulla_J
2 Solutions
 
daniel_ballaCommented:
Hi Rahamathulla_J,

XmlDocument xDoc = new XmlDocument();
xDoc.Load("your file path here");

string yourTagValue = xDoc.SelectSingleNode("your XPath").InnerText;

Cheers!
Dani
0
 
brazzleCommented:
or if you wish to create a class to encapsulate the process you can do this:

public string ParseXML(string path, string tag)
{
    XmlDocument xD = new XmlDocument();
    xD.Load(path);

    //use xml classes to perform methods

    return result;
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now