c# - SyndicationFeed: How to access content:encoded? -
in windows 8 store app i'm reading xml data using syndicationfeed
. few items of rss feeds contain example content:encoded
(xmlns:content='...') elements. think there's no way content of these elements through syndicationitem?!
that's why try inside foreach(syndicationitem item in feeditems)
this:
item.getxmldocument(feed.sourceformat).selectsinglenode("/item/*:encoded]").innertext;
but doesn't work. , i'm note sure how use namespacemanager
etc. in winrt. i'm accessing content:encoded via nextsibling
method of other element, that's not clean way.
so how can access content of element best?
<?xml version="1.0" encoding="utf-8" ?> <rss version="2.0" xmlns:content="uri"> <channel> <.../> <item> <title>example entry</title> <description>here text containing interesting description.</description> <link>http://www.wikipedia.org/</link> <content:encoded>content try access</content:encoded> </item> </channel> </rss>
just use xnamespace
xnamespace content = "uri"; var items = xdocument.parse(xml) .descendants("item") .select(i => new { title = (string)i.element("title"), description = (string)i.element("description"), link = (string)i.element("link"), encoded = (string)i.element(content + "encoded"), //<-- *** }) .tolist();
Comments
Post a Comment