When is XML not XML?

Here is a mystery for folks. I’ve updated my parsing engine for coldfusionbloggers.org. I’m using CFHTTP now so I can check Etag type stuff. I take the result text and save it to a file to be parsed by CFFEED.

But before I do that I check to ensure it’s valid XML. Here is where it gets weird. Charlie Griefer’s blog works with CFFEED directly, but isXML on the result returns false. But - I can xmlParse the string no problem. Simple example:

<cfset f= "http://cfblog.griefer.com/feeds/rss2-0.cfm?blogid=30"> <cfhttp url="#f#"> <cfset text = cfhttp.filecontent>

<cfif isXml(text)> yes <cfelse> no <cfset z = xmlParse(text)> <cfdump var=”#z#”> </cfif> </code>

If you run this, you will see “no” output, and than an XML object. If you use CFFEED on the URL directly, that works as well. So it seems like isXML is being strict about something. I can update my code to try/catch an xmlParse obviously, but I’d rather figure out why the above is happening first.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments