I am trying to read XML-RSS-Feed from a website. Therefore, I use asynchronous loading and create XDocumentusing the method XDocument.Parse().
The document intends to be very simple, for example:
<root>
<someAttribute></SomeAttribute>
<item>...</item>
<item>...</item>
</root>
Now I want to read all the elements. So I tried:
foreach (XElement NewsEntry in xDocument.Descendants("item"))
but it does not work. Therefore, I found a message on this board for using a qualified name, because some namespaces are defined in the root element:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns="http://purl.org/rss/1.0/">
well, I tried all 3 available namespaces - nothing worked for me:
XName itemName = XName.Get("item", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
XName itemName2 = XName.Get("item", "http://purl.org/dc/elements/1.1/");
XName itemName3 = XName.Get("item", "http://purl.org/rss/1.0/modules/syndication/");
Any help would be greatly appreciated. (I usually do XML analysis with Regex, but this time I'm developing for a mobile device and therefore should take care of performance.)