Issue parsing RSS xml

Posted by cw on Stack Overflow See other posts from Stack Overflow or by cw
Published on 2010-03-30T01:43:13Z Indexed on 2010/03/30 1:53 UTC
Read the original article Hit count: 506

Filed under:
|

Hello, I'm having an issue using Linq to XML parsing the following XML. What I am doing is getting the element checking if it's what I want, then moving to the next. I am pretty sure it has to do with the xmlns, but I need this code to work with both this style and normal style RSS feeds (no xmlns). Any ideas?

    <?xml version="1.0" encoding="UTF-8"?>
        <rdf:RDF xmlns:rdf="http://someurl" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<channel rdf:about="http://someurl">

            XElement currentLocation  = startElementParameter;
            foreach (string x in ("channel\\Title").Split('\\'))
            {
                if (condition1 == false)
                {
                    continue;
                }
                else if (condition2 == false)
                {
                    break;
                }
                else
                {
                    // This is returning null.
                    currentLocation = currentLocation.Element(x);
                }
            }

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about rss