I'm building an application that needs to run through an XML feed but I'm having a little trouble with getting certain elements.
I'm using the Twitter feed and want to run through all the <item>
elements. I can connect fine and get the content from the feed but I can't figure out how to select only the item
elements when I'm loopuing through reader.Read();
.
Thanks for your help!
An alternative:
I don't know if this code is slower or bad practice. Please do comment.
I find it more readable than the other one using Navigator and Iterator.
Edit: I use an XmlDocument. An XPathDocument as in Vinko Vrsalovic 's answer doesn't support this way of working, but is a lot faster: (MSDN)
The easiest way to do that is to use XPath. Example to follow.
And this is jan's approach working