Yanshof
Yanshof

Reputation: 9926

Most efficient way to look for value in xml file?

I have an XML file that I need to get some value from.

There are several ways to do it:

Upvotes: 2

Views: 668

Answers (3)

raj_jboss
raj_jboss

Reputation: 69

Ok, if you are not satisfied with Linq then try below explainer... http://www.codeproject.com/Questions/658297/XMLDocument-vs-XDocument-vs-XmlReader-vs-LINQ-to-X

Upvotes: 2

raj_jboss
raj_jboss

Reputation: 69

Easy way to parse the xml is to use the LINQ to XML https://msdn.microsoft.com/en-us/library/bb387061(v=vs.90).aspx may be useful

Upvotes: 0

DONG
DONG

Reputation: 54

try this

string path = Server.MapPath("[pathofXMLFile]"); 
System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
xml.Load(path);
System.Xml.XmlNodeList t = xml.GetElementsByTagName("[tagname]"); 
string ht = t[0].InnerXml;

use relative path in locating your xml file hope this help you thanks

Upvotes: 1

Related Questions