Sunday 15 September 2013

Get All XML ChildNodes with Specific Type

Get All XML ChildNodes with Specific Type

Given the following code:
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlElement root = doc.DocumentElement;
What is the most efficient way to get all the child nodes of root that are
of type "item". There can be more than one such item type. But most items
are of other types.
I know I can do this:
root["item"];
But that only returns a single element. How can I do the same thing but
return all elements of that type?
Thanks!

No comments:

Post a Comment