tags:

views:

214

answers:

1

Getting an error on occasion on a specific CF page. Offending code listed below. Very odd because when I rebooted CF it went away. Can the XML be checked via XMLValidate to prevent this from happening?

Is this some sort of CF bug since the error disappeared after reboot of CF? I have a feeling that the error will resurface at some point.

An error occured while Parsing an XML document. The element type "meta" must be terminated by the matching end-tag "".

<cfhttp method="get" url="http://bs.mysite.com/webservice/rec/get.sbs?customerId=345S4BE8x&amp;itemId=#product_id#&amp;number=20&amp;ruleId=#product.location_tab_accessories#"&gt;

<cfset result = xmlParse(cfhttp.FileContent)>
<cfset recs = xmlSearch(result, "/result/thsite/site/itemId")>
+8  A: 

You can use XmlValidate() to validate a xml doc against a DTD or a Schema. XmlParse() itself validates the document and throws an error if the xml is not well formed. It also supports a validator parameter as of CF7. Use cftry/cfcatch to handle the exception.

The error message you received indicates that you didn't receive the XML document you expected, but a HTML page with unclosed meta tags in it. Maybe this could be a error page or some other html page you've been redirected to.

Did something change with DNS/IP of the target URL? Cfhttp does DNS caching (the underlying JVM does) and this can lead to strange effects like you experienced here. Restarting ColdFusion clears the cache, the url is resolved again and your request will be successful.

Andreas Schuldhaus
Agreed. I would recommend trapping/logging the content received when this error occurs and looking at it to see if/why it's not the XML you're expecting.
Adam Tuttle