ColdFusion 10 broken xmlSearch()

Ever since I upgraded to ColdFusion 10 I’m discovering a lot of little “gotchas”.  Today’s seems to be a change / bug in backwards compatibility of xmlSearch().  ColdFusion 10 added support for XPath 2.0 which adds a lot of great new features I really haven’t played with yet.  However, it seems like some things from XPath 1.0 are no longer supported, or just left out of compatibility.

Here is an example.  I have a modified Amazon S3 CFC wrapper service that I use.  It’s first function that gets xmlSearch() use is a call to “getBuckets”.

Here is the xml being returned:

<xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="">

This search used to work, but it doesn’t now:

local.buckets = xmlSearch(local.apiCall.response, "//:Bucket");

The above search now throws a dreaded “XMLSearch for Unexpected colon at start of token” error.  The namespace didn’t change and this colon was an alias to the namespace as I understand it.

After some searching, I found the answer I needed (as usual) on stackoverflow.

Here is the revised and working xmlSearch():

local.buckets = xmlSearch(local.apiCall.response, "//*[local-name()='Bucket' and namespace-uri()='']");

I have a lot of xmlSearch() to fix now..

Leave a Reply