Return to Snippet

Revision: 54725
at January 9, 2012 22:12 by stentebjerg


Initial Code
@using System.Xml.XPath;
@using System.Xml;

@{
    //Fetch RSS XML
    XmlTextReader udBrudRSS = new XmlTextReader("http://myblog.com/rss");
    
    //Create new XML document
    XmlDocument doc = new XmlDocument();
    
    //Load in our remote XML into our XML document
    doc.Load(udBrudRSS);
    
    //Select our nodes we want with some xPath
    XmlNodeList rssItems = doc.SelectNodes("//item");
  
}
<ul>
    @{
        //For each item node we can then ouput what we want
        foreach (XmlNode node in rssItems)
        { 
         
         
         
            <li>
                <div class="date">@node["pubDate"].InnerText</div>
                <a href="@node["link"].InnerText">@node["title"].InnerText<span></span></a>
            </li>
        }
    }
</ul>

Initial URL

                                

Initial Description
Razor snippet that fetch external RSS feed in Umbraco.

Initial Title
Razor fetch RSS XML

Initial Tags

                                

Initial Language
C#