Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi expert,

I have to add rss news module for IPL news with images.

and i am using following rss link.
http://www.indiatvnews.com/rssfeed/sports_cricket_news.php[^]

But this rss news feeds is regarding cricket which showing all news from cricket.

Now how i can display those news result which contains only ipl keyword from above xml.

how i can search keyword from xml.

Please help me.
Thanks in advance.
Posted
Comments
Lakamraju Raghuram 17-Apr-12 3:36am    
I have checked the RSS feed you gave. They are having nodes classifying it as IPL. And scanning for IPl keyword may not give you correct results. Think of some other feed which this type of classification
udusat13 17-Apr-12 3:47am    
Thanks,

But according to you,i haven't found any special node for IPL in that xml.
Please tell me, if i missing something.
Lakamraju Raghuram 17-Apr-12 4:29am    
You haven't missed any thing. There is no node.

1 solution

Intereting question: filtering XML by a substring in a CDATA...

See http://stackoverflow.com/questions/568315/how-do-i-retrieve-element-text-inside-cdata-markup-via-xpath[^] to get the contents of a CDATA in a XPath query.
You may need an XPath query like //item[fn:contains(/description/InnerText(),"IPL")]
(not tested).

More on 'contains': http://www.w3schools.com/xpath/xpath_functions.asp[^]

Hope this helps,
 
Share this answer
 
Comments
VJ Reddy 17-Apr-12 4:35am    
Good answer. 5!
udusat13 17-Apr-12 5:32am    
Thanks ,

I have tried like following
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="http://www.indiatvnews.com/rssfeed/sports_cricket_news.php"
XPath="/item[fn:contains(/description/InnerText(),'IPL')]">

but it gives exception
System.Xml.XPath.XPathException: 'rss/channel/item[fn:contains(/description/InnerText(),'IPL')]' has an invalid token.

please help me.

Thanks again
Pablo Aliskevicius 17-Apr-12 5:51am    
Off the top of my head, I can suggest two things:
1. Start your query with a double slash: XPath="//item.. insted of XPath="/item
2. Try debugging the XPATH part by part:

XPath="//item/description"
XPath="//item/description/InnerText()"
XPath="//item/description/[fn:contains(InnerText(),'IPL')]"
XPath="//item[fn:contains(/description/InnerText(),'IPL')]"
XPath="fn:contains(//item/description/InnerText(),'IPL')"

I'm a little rusty about how fn:contains works, and which namespaces you should import.
When you get it to work, please share the query!

Hope this helps,
Pablo.
udusat13 21-Apr-12 0:32am    
Thanks for your solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900