Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use a combination of LINQ and XPathNavigator to extract the syndication extensions of a feed item (based on namespace URI of the extension). For item enclosures, you will want to examine the item links collection for links that have a RelationshipType of <em>enclosure</em>.</p> <p>Example:</p> <pre><code>HttpWebRequest webRequest = WebRequest.Create("http://www.pwop.com/feed.aspx?show=dotnetrocks&amp;filetype=master") as HttpWebRequest; using (Stream stream = webRequest.GetResponse().GetResponseStream()) { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreWhitespace = true; using(XmlReader reader = XmlReader.Create(stream, settings)) { SyndicationFeed feed = SyndicationFeed.Load(reader); foreach(SyndicationItem item in feed.Items) { // Get values of syndication extension elements for a given namespace string extensionNamespaceUri = "http://www.itunes.com/dtds/podcast-1.0.dtd"; SyndicationElementExtension extension = item.ElementExtensions.Where&lt;SyndicationElementExtension&gt;(x =&gt; x.OuterNamespace == extensionNamespaceUri).FirstOrDefault(); XPathNavigator dataNavigator = new XPathDocument(extension.GetReader()).CreateNavigator(); XmlNamespaceManager resolver = new XmlNamespaceManager(dataNavigator.NameTable); resolver.AddNamespace("itunes", extensionNamespaceUri); XPathNavigator authorNavigator = dataNavigator.SelectSingleNode("itunes:author", resolver); XPathNavigator subtitleNavigator = dataNavigator.SelectSingleNode("itunes:subtitle", resolver); XPathNavigator summaryNavigator = dataNavigator.SelectSingleNode("itunes:summary", resolver); XPathNavigator durationNavigator = dataNavigator.SelectSingleNode("itunes:duration", resolver); string author = authorNavigator != null ? authorNavigator.Value : String.Empty; string subtitle = subtitleNavigator != null ? subtitleNavigator.Value : String.Empty; string summary = summaryNavigator != null ? summaryNavigator.Value : String.Empty; string duration = durationNavigator != null ? durationNavigator.Value : String.Empty; // Get attributes of &lt;enclosure&gt; element foreach (SyndicationLink enclosure in item.Links.Where&lt;SyndicationLink&gt;(x =&gt; x.RelationshipType == "enclosure")) { Uri url = enclosure.Uri; long length = enclosure.Length; string mediaType = enclosure.MediaType; } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload