Parse XML file

Posted on 2006-10-20
Last Modified: 2010-04-16
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#?
Question by:Rahamathulla_J

Assisted Solution

daniel_balla earned 125 total points
ID: 17772451
Hi Rahamathulla_J,

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

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


Accepted Solution

brazzle earned 125 total points
ID: 17774203
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();

    //use xml classes to perform methods

    return result;

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now