RSS and XPath
I came across a handy reference article on xml.com today that gives XPath queries for RSS and Atom feeds. Just last week I was attempting to parse a RSS 1.0 feed in CFMX using the XMLSearch function. I'm running into problems however due to the name spaces in RSS 1.0, here's the code I'm using:
<cfhttp url="http://www.fullasagoog.com/xml/ColdFusionMX.xml" method="get" /> <cfset rss = XMLParse(cfhttp.filecontent)> <!--- get an array of items ---> <cfset items = XMLSearch(rss, "/rdf:RDF/item")> <cfdump var="#items#">
The result is that the items array is empty. I think this is a namespace issue, but I'm not really sure. Is this a bug? Anyone have an idea?
BTW if your looking to parse RSS 0.9x or 2.0 with XPath check out this older blog post.
Like this? Follow me ↯Tweet Follow @pfreitag
RSS and XPath was first published on April 08, 2004.
If you like reading about rss, xpath, cfml, coldfusion, xml, or xmlsearch then you might also like:
- Parsing RSS 1.0 with ColdFusion MX
- Top 10 Underrated Functions in ColdFusion
- Foundeo's 2007 End of the Year Sale
- XPath Tool
- Parsing RSS with CFMX
- Dumping HTTP Servlet Request Attributes and Parameters in CF
- 6 ways to stay connected with other CF developers
- ColdFusion Function Arguments now support Integer
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.