c# - Linq to XML : Problem with colon in the xml tags -
here's code retrieve value in content tag:
var returnverse = item in xmltreeverse.descendants("rss").elements("channel").elements("item") select new versemodel { verse = item.element("content").value, url = "" };
here's xml file:
<?xml version="1.0" ?> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/"> <channel> <title>text</title> <link>text</link> <item> <title>text</title> <content:encoded> text </content:encoded> </item> </channel> </rss>
i can't query "content:encode" because invalid query ":" operator. please help.
that "colon operator" namespace. need query namespace well. use namespaces this:
xnamespace content = xnamespace.get("http://purl.org/rss/1.0/modules/content/"); verse = item.element(content + "encoded").value
Comments
Post a Comment