Solved

Parse XML file

Posted on 2006-10-20
4
228 Views
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#?
0
Comment
Question by:Rahamathulla_J
4 Comments
 
LVL 9

Assisted Solution

by:daniel_balla
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;

Cheers!
Dani
0
 
LVL 2

Accepted Solution

by:
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();
    xD.Load(path);

    //use xml classes to perform methods

    return result;
}
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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