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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -