I have an xml document like so
<cfxml variable="mydoc">
<?xml version="1.0" encoding="UTF-8"?>
<Feed xmlns="http://www.example.com/xs/PRR/SyndicationFeed/4.9" name="Test">
<Product id="test1" removed="false">
<Source>Widget</Source>
<ExternalId>Widget01</ExternalId>
<Name>iWidget 3G</Name>
<NumReviews>11</NumReviews>
</product>
</Feed>
</cfxml>
I want to return the NumReviews node text. However:
numReviews = XmlSearch(mydoc, "/Feed/Product/NumReviews"); returns an empty array.
While numReviews = XmlSearch(myDoc, "//*[local-name()='NumReviews']"); returns the node text.
As far as I can tell, the first line of code is correct and should return the value of NumReviews. Why is it instead returning an empty array?
And it may be the name spaces. I think your second syntax is required when namespaces are involved. I know I’ve had to use it myself.