|
Neal,
If the data within the CDATA tag is XML you could extract
and parse it with something like the following:
<cfset parsedContent =
xmlParse(...content.xmlText)>
Where ... is the path to the <content:encoded>
tag.
If the data is not XML data then you just extract it with
the .xmlText method I believe. (caviat - I have not extracted data wrapped
in the CDATA tags for a couple of years now)
Hope this helps,
Tom
From: Bailey, Neal
[mailto:[EMAIL PROTECTED]
Sent: Monday, November 08, 2004 11:15 AM To: [EMAIL PROTECTED] Subject: Parsing RSS/RDF Help... 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 |
- RE: Parsing RSS/RDF Help... Tom Woestman
- RE: Parsing RSS/RDF Help... Bailey, Neal
- Re: Parsing RSS/RDF Help... Adrian J. Moreno
- RE: Parsing RSS/RDF Help... Ken Ferguson
- RE: Parsing RSS/RDF Help... Bailey, Neal
