Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Scott Robinson 54 posts 75 karma points
    Jul 01, 2013 @ 11:25
    Scott Robinson
    0

    Extracting image from RSS text

    Hi,

    I'm using this script, kindly posted on this forum that lists items from an rss. My issue is I have a <img> that is contanined within the <description> that I wish to remove and position above the <title>. The way it renders is:

    <title></title>

    <description><img> body copy </description>

    What I need is:

    <img>

    <title></title>

    <description></description>

    Any idea how I would do this. The script I am using is:

     

    @using System.Xml;

     

    @{

        //Get the XML from remote URL

        XmlDocument xml = new XmlDocument();

     

        //URL currently hardcoded - but you could use a macro param to pass in URL

        xml.Load("http://ebiquityopinion.com/?feed=rss2");

     

        //Select the nodes we want to loop through

        XmlNodeList nodes = xml.SelectNodes("//item");

     

        //Traverse the entire XML nodes.

        foreach (XmlNode node in nodes)

        {

            //Get the value from the <title> node

            var title = node.SelectSingleNode("title").InnerText;

     

            //Get the value from the <description> node

            var description = node.SelectSingleNode("description").InnerText;

          <li>  

            <h3><strong>@title</strong></h3>

            @Html.Raw(description)

            </li>

        } 

    }

    </ul>

Please Sign in or register to post replies

Write your reply to:

Draft