ColdFusion doesn’t like the xmlns attribute

For some reason CF doesn’t like the xmlns attribute in the root node of an XML document. If you attempt to use a valid XPath statement in the xmlSearch function the array that’s returned will be empty. Strip it out like so:

<cfset myXMLDoc = xmlParse(myXMLDoc)/>
<cfset myXMLDoc = reReplaceNoCase(myXMLDoc,'xmlns=".*?"',"","all")/> 

Just another one of those, “who’s fault is this: mine or ColdFusion’s?” I ran into this a long time ago and forgot about it. After the 10th request attempting to figure it out, it occurred to me. doh.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*

*