Coldfusion / XML Error

410 Views Asked by At

I'm using Open BlueDragon since it's what my web hosting company use - plus it's open source.

I'm trying to read a YouTube feed using XML, and I keep getting the following error:

value [media:group] is not a number

My code is:

<cfhttp url="https://gdata.youtube.com/feeds/api/users/Shuggy23/favorites" method="GET" />
<cfset xml = XmlParse(#cfhttp.FileContent#) />
<cfoutput>#xml.feed.entry["media:group"]["media:thumbnail"].XmlAttributes.url#</cfoutput>

I think it worked before unless my mind was playing tricks on me. Any help would be appreciated.

Thank you

Douglas

2

There are 2 best solutions below

0
On

Sorry - that code works perfectly fine on CF9, BlueDragon specific I suppose. what if you tried a different set of data - might lead to a clue:

#xml.feed.entry["gd:comments"]["gd:feedlink"].XmlAttributes.href#

If that fails as well I would suspect either the quote syntax or the colon notation, then try the BlueDragon docs & user forums.

Sorry I couldn't help more.

-sean

1
On

This work on BD if you change your reference to xml.feed.entry[1]["gd:comments"]["gd:feedlink"].XmlAttributes.href. Note that I've specified WHICH entry node you mean. CF is clever enough to work out you were meaning the FIRST "entry" node (is that what you meant?). BD is a bit more literal... it sees an array of "entry" nodes, so you need to specify which element of the array.

This simplified code demonstrates it:

<cfflush interval="1">
<cfxml variable="x">
    <a>
        <b><c>d</c></b>
        <b><c>e</c></b>
    </a>
</cfxml>
<cfoutput>x.a.b[1]["c"].xmlText: #x.a.b[1]["c"].xmlText# (OK on both platforms)<br /></cfoutput>
<cftry>
    <cfoutput>x.a.b["c"].xmlText: #x.a.b["c"].xmlText# (OK on CF only)<br /></cfoutput>
    <cfcatch>
        <cfdump var="#cfcatch#">
        <cfdump var="#x#">
    </cfcatch>
</cftry>

HTH