Access XML element directly
C#
2
Posts
2
Posters
0
Views
1
Watching
-
I am using an iterator, which iterates through the xml file and reads each node. Can I access an element directly if it has an unique name?
Yes you can if you know the XPath to it one example of doing this could be something like -
XmlDocument doc = new XmlDocument(); doc.LoadXml(""); /*DocumentElement is always the root element of the xml and the parameter supplied in the selectSingleNode method is the XPath*/ XmlNode node = doc.documentElement.selectSingleNode("//element2");