Reading CDATA text from RSS Feed using LINQ to xml
-
Hi, I have the following RSS Feed containing a CDATA Tag. I wish to get the "img src" attribute information, but i am unable to get it. Can anybody help please !!!. I am using LINQ to XML. Please give LINQ solutions only...
<description><![CDATA[
<img src="http://l.yimg.com/a/i/us/we/52/30.gif"/><br />
<b>Current Conditions:</b><br />
Partly Cloudy, 37 C<BR />
<BR /><b>Forecast:</b><BR />
Fri - Sunny/Wind. High: 39 Low: 25<br />
Sat - Sunny/Wind. High: 42 Low: 26<br />
<br />
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Islamabad\_\_PK/\*http://weather.yahoo.com/forecast/PKXX0006\_c.html">Full Forecast at Yahoo! Weather</a><BR/><BR/>
(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>
]]></description>Thank you in advance...
-
Hi, I have the following RSS Feed containing a CDATA Tag. I wish to get the "img src" attribute information, but i am unable to get it. Can anybody help please !!!. I am using LINQ to XML. Please give LINQ solutions only...
<description><![CDATA[
<img src="http://l.yimg.com/a/i/us/we/52/30.gif"/><br />
<b>Current Conditions:</b><br />
Partly Cloudy, 37 C<BR />
<BR /><b>Forecast:</b><BR />
Fri - Sunny/Wind. High: 39 Low: 25<br />
Sat - Sunny/Wind. High: 42 Low: 26<br />
<br />
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Islamabad\_\_PK/\*http://weather.yahoo.com/forecast/PKXX0006\_c.html">Full Forecast at Yahoo! Weather</a><BR/><BR/>
(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>
]]></description>Thank you in advance...
-
Just access the RSS feed(XML content) in your dataset , after getting in your dataset you can do wat ever you want.
If you guide me a bit further... 1. I have loaded the document as follows.
XDocument rssFeed = XDocument.Load(sForecastUrl);
2. Now i get the descendant nodes as follows
var desc = from e in rssFeed.Descendants("channel").Descendants("item").Descendants("description")
select e;foreach (var element in desc) { element.Value; }
I am able to get description element value which contains the cdata tag. Dont know what to do next to get "Img Src" attribute directly rather than from string manipulation. Some code in the foreach loop should help please.
-
If you guide me a bit further... 1. I have loaded the document as follows.
XDocument rssFeed = XDocument.Load(sForecastUrl);
2. Now i get the descendant nodes as follows
var desc = from e in rssFeed.Descendants("channel").Descendants("item").Descendants("description")
select e;foreach (var element in desc) { element.Value; }
I am able to get description element value which contains the cdata tag. Dont know what to do next to get "Img Src" attribute directly rather than from string manipulation. Some code in the foreach loop should help please.
-
No No... Get the XML and convert the XML to DATASET using dataset.readxml() you will get all tags as columns and its attributes , so you can easily get the attribute value.
Oh!!! I understood your point on using datasets, but i have written all my work using linq to xml. i have successfully parsed whole of the xml document already, only part missing was this cdata tag, so i was asking for finding a solution to that using linq as well. i don't want to load the complete document as dataset again, i have already loaded the webresponse into xDocument. So any solution relating to that... Even though i can get the url out from the attribute using string manipulation but clearly that is not the right method. P.s. Thanks for the dataset option though....