Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RSS w/ CFHTTP

Status
Not open for further replies.

metaphiz

Programmer
Jun 30, 2004
91
US
I'm trying to output dynamically generated links from a RSS feed, but I
don't know how to refer to the href property of an XML tag in the
output page of the feed. When the XML input is like <entry>
<title>Latest CD releases as of June 12, 2007</title></entry>, the
code is #xmlDoc.feed.entry.title.xmlText#, but now I want to output
the href property of a link tag in the XML, like this: <entry><link
rel="alternate" type="text/html" href="entertainment/2007/06/latest_cd_releases_as_of_june.html" /></
entry>

I'm getting a java error when I try: #xmlDoc.feed.entry
.link.href.xmlText#

Here's the actual code from the XML page and the feed output page:

XML PAGE CODE (INPUT)
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="<entry>
<link rel="alternate" type="text/html" href="entertainment/2007/06/latest_cd_releases_as_of_june.html" />
</entry>
</feed>

RSS OUTPUT PAGE CODE (OUTPUT):
<cfhttp url="method="get" timeout="5" path="D:\GearHost\HostingAccounts
\metaphiz7\ file="nola_entertainment.rdf" />
<cffile action="read" file="D:\GearHost\HostingAccounts\metaphiz7
\ variable="FileContent">
<cfset xmlDoc = XMLParse(filecontent)>

<cfoutput>
<cfloop from="1" to="#ArrayLen(xmlDoc.feed.entry)#" index="i">
<cfset gDate = Len(xmlDoc.feed.entry.published.xmlText) - 6>
<a href="#xmlDoc.feed.entry.link.xmlText#">Read More</a></
td></tr><tr><td> </td></tr>
</cfloop>
</cfoutput>
 
nearly. the href value is an attribute of the link node, so you need to refer to it as such. this should do you:


Code:
<cfhttp url="[URL unfurl="true"]http://blog.nola.com/entertainment/atom.xml"[/URL] method="get" />

<cfset xmlDoc = XMLParse(cfhttp.filecontent)>

<cfloop from="1" to="#ArrayLen(xmlDoc.feed.entry)#" index="i">
	<cfoutput>
		#xmlDoc.feed.entry[i].link.xmlattributes.href#<br>
	</cfoutput>
</cfloop>

hope this helps!

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top