|
Hey Guys… How the heck do you parse RSS/RDF feeds with the <content:encoded> tag? --------------------------------------------- - <content:encoded> - <![CDATA[ My Formatted Text goes here. ]]> </content:encoded> ---------------------------------------------- Here is my code… I am trying to parse an xml feed from
the Steam network, with all the new Half-Life2 News for my Game site. I can
parse any other type of RSS feed or XML feed but this one is tripping me up. -------------Start
Code--------------------------------------- <cfset feedUrl
= "http://steampowered.com/rss.xml"> <cfhttp url="#feedUrl#"
method="get" /> <cfset rss
= XMLParse(cfhttp.filecontent)> <!--- get an
array of items ---> <cfset items = XMLSearch(rss, "//:item")> <!---cfdump var="#items#"--->
<cfset rssItems
= QueryNew("title,content,link")> <!--- loop
through the array of items ---> <cfloop from="1"
to="#ArrayLen(items)#" index="i"> <cfset row = QueryAddRow(rssItems)> <cfset title = XMLSearch(rss, "//:item[#i#]/:title")> <cfif ArrayLen(title)>
<cfset title = title[1].xmlText> <cfelse>
<cfset title=""> </cfif> <cfset content = XMLSearch(items[i], "//:item[#i#]/:content")> <cfif ArrayLen(content)>
<cfset content = content[1].xmlText> <cfelse>
<cfset content=""> </cfif> <cfset link = XMLSearch(items[i], "//:item[#i#]/:link")> <cfif ArrayLen(link)>
<cfset link = link[1].xmlText> <cfelse>
<cfset link=""> </cfif> <!--- add to query ---> <cfset QuerySetCell(rssItems, "title", title, row)> <cfset QuerySetCell(rssItems, "content", content, row)> <cfset QuerySetCell(rssItems, "link", link, row)> </cfloop> <ul> <cfoutput query="rssItems"> <li><a href="#rssItems.link#">#rssItems.title#</a>
- #rssItems.content#</li>
</cfoutput> </ul> --------------END------------------------------------------- Thanks
for any help you can spare… - Neal
Bailey |
- Parsing RSS/RDF Help... Bailey, Neal
- Re: Parsing RSS/RDF Help... Adrian J. Moreno
- RE: Parsing RSS/RDF Help... Tom Woestman
- RE: Parsing RSS/RDF Help... Bailey, Neal
- RE: Parsing RSS/RDF Help... Ken Ferguson
- RE: Parsing RSS/RDF Help... Bailey, Neal
