I'm currently delving into the wonderful world of XML.. After having a bit of a tinker with an XML set up there is one thing that has me stumped which I noticed when trying to build a navigation. I'll set up an example below to demonstrate my issue.
<cfxml variable="myXML">
<navigation>
<navItem>
<name>Mens</name>
</navItem>
<navItem>
<name>Womens</name>
</navItem>
</navigation>
</cfxml>
<cfset navList = arrayToList(xmlSearch(xmlParse(myXML),
"string(//navItem/name/text()), "^")>
<cfloop list="#navList#" delimiter="^" index="nav">
<cfoutput>
#nav#
</cfoutput>
</cfloop>
My aim is to have this:
Mens
Womens
This may begin to make sense to some now. I'm trying to return the name value as a string of EACH <navItem> within the XML tree. Of course the error i'm being thrown does make sense, however now i'm stuck as to how I go about returning multiple nodes values as strings.
The error I recieve states:
Unable to process the result of the XMLSearch for A sequence
of more than one item is not allowed as the first argument
of string() (text("Mens"), text("Womens")).
Followed by:
ColdFusion is unable to process the result of the XPath search.
You may have an undefined variable in the xpath expression.
Can anyone point in me along the right lines of what im after?