Question

I am using a RadRotator as following for getting an RSS feed from google:

     <telerik:RadRotator ID="RadRotator1" RotatorType="AutomaticAdvance" ScrollDirection="Up"
            ScrollDuration="2000" runat="server" DataSourceID="XmlDataSource1" Width="493"
            ItemWidth="493" Height="192" ItemHeight="75" FrameDuration="1" InitialItemIndex="-1"
            CssClass="rotator"> 

                    <%#   XPath("item") %>    



      </ItemTemplate>

What is happening is that nothing is showing in the radgrid when I do

    <%#   XPath("item") %>  

Note that I need item as this is has the title, desciption etc. a you can see in the sniplet below

but if I do

   <%#   XPath("description") %> 

I see the description but the item is what I need..

Here is what a sniplet of the google rss xml file looks like:

    <rss version="2.0"><channel><generator>NFE/1.0</generator><title>malaria - Google News</title><link>http://news.google.com/news?pz=1&ned=us&hl=en&q=malaria</link><language>en</language><webMaster>news-feedback@google.com</webMaster><copyright>&copy;2012 Google</copyright><pubDate>Thu, 25 Oct 2012 14:56:08 GMT</pubDate><lastBuildDate>Thu, 25 Oct 2012 14:56:08 GMT</lastBuildDate><image><title>malaria - Google News</title><url>https://ssl.gstatic.com/news/img/logo/en_us/news.gif</url><link>http://news.google.com/news?pz=1&ned=us&hl=en&q=malaria</link></image><item><title>Malaria and Acquired Immunity - AllAfrica.com</title><link>http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNHNkVuoonL7HkcwkSoAldZPsWUvNg&url=http://allafrica.com/stories/201210251151.html</link><guid isPermaLink="false">tag:news.google.com,2005:cluster=http://allafrica.com/stories/201210251151.html</guid><pubDate>Thu, 25 Oct 2012 12:16:20 GMT</pubDate><description><table border="0" cellpadding="2" cellspacing="7" style="vertical-align:top;"><tr><td width="80" align="center" valign="top"><font style="font-size:85%;font-family:arial,sans-serif"></font></td><td valign="top" class="j"><font style="font-size:85%;font-family:arial,sans-serif"><br /><div style="padding-top:0.8em;"><img alt="" height="1" width="1" /></div><div class="lh"><a href="http://news.google.com/news/url?sa=t&amp;fd=R&amp;usg=AFQjCNHNkVuoonL7HkcwkSoAldZPsWUvNg&amp;url=http://allafrica.com/stories/201210251151.html"><b><b>Malaria</b> and Acquired Immunity</b></a><br /><font size="-1"><b><font color="#6f6f6f">AllAfrica.com</font></b></font><br /><font size="-1">Even though the economic impact in Zambia has not yet been quantified, it is likely to be substantial due to the number of productive days lost due to the number of productive days lost due to <b>malaria</b>. The intensity of <b>malaria</b> in an area determines the <b>...</b></font><br /><font size="-1" class="p"></font><br /><font class="p" size="-1"><a class="p" href="http://news.google.com/news/more?ncl=dPdXW_JAl88mIRM&amp;ned=us"><nobr><b>and more&nbsp;&raquo;</b></nobr></a></font></div></font></td></tr></table></description></item>

Note that I am just trying to get the item portion of it as the item is the wrapper for description,etc.

Was it helpful?

Solution

here is the code snippet for your scenario:

XML Data Source Definition:

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="http://news.google.com/news?pz=1&amp;cf=all&amp;ned=us&amp;hl=en&amp;q=malaria&amp;output=rss" 
                XPath="rss/channel/item"></asp:XmlDataSource>

RadRotator definition:

        <telerik:RadRotator ID="RadRotator1" RotatorType="AutomaticAdvance" ScrollDirection="Up"
            ScrollDuration="1000"  runat="server" DataSourceID="XmlDataSource1" Width="493"
            ItemWidth="493" Height="250" ItemHeight="250" FrameDuration="2000" InitialItemIndex="-1"
            CssClass="rotator">
            <ItemTemplate>
                <div style="border: 1px solid darkgray; padding : 10px;background-color:lightgrey">
                    <a href='<%# XPath("link") %>'><%# XPath("title") %></a>
                    <div>
                        <%# XPath("description") %>
                    </div>
                </div>

            </ItemTemplate>
        </telerik:RadRotator>

The way to reach an item in RSS feed is through the path rss/channel/item - this will give all the items in the document. Then in the item template i am just grabbing the link, title and description. Item is a parent node and thats why

Here is the output of the above code:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top