Skip to content Skip to sidebar Skip to footer

Python's Xml.etree Getiterator Equivalent To C#

I have this XML file : http://dl.dropbox.com/u/10773282/2011/perf.xml It has two Class elements as is marked. I need to get two nodes with C#. With Python, I can easily get them w

Solution 1:

You should try Linq to XML... Quite easy to use:

var xml = XDocument.Load(filename);
var res = from p in xml.Root.Elements("Class").Elements("ClassKeyName") select p.Value;

Solution 2:

Try:

using System.Xml;
// ...
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filename);
var matches = xmlDoc.SelectNodes("//Class/ClassKeyName");

Post a Comment for "Python's Xml.etree Getiterator Equivalent To C#"