Xml 使用XPath中的string()函数以字符串形式返回多个节点
我目前正在深入研究XML的奇妙世界。。在对XML设置进行了一些修补之后,有一件事让我感到困惑,我在尝试构建导航时注意到了这一点。我将在下面举一个例子来说明我的问题Xml 使用XPath中的string()函数以字符串形式返回多个节点,xml,xpath,coldfusion-10,Xml,Xpath,Coldfusion 10,我目前正在深入研究XML的奇妙世界。。在对XML设置进行了一些修补之后,有一件事让我感到困惑,我在尝试构建导航时注意到了这一点。我将在下面举一个例子来说明我的问题 <cfxml variable="myXML"> <navigation> <navItem> <name>Mens</name> </navItem> <navItem>
<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>
现在,这对一些人来说可能开始有意义了。我试图以XML树中每个
的字符串形式返回名称值。当然,我抛出的错误是有意义的,但是现在我被困在如何将多个节点值作为字符串返回的问题上
我收到的错误说明:
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")).
其次是:
ColdFusion is unable to process the result of the XPath search.
You may have an undefined variable in the xpath expression.
有人能告诉我我想要什么吗?我只想试试
<cfset navList = arrayToList(xmlSearch(xmlParse(myXML), "//navItem/name"), "^")>
如果那不行的话
<cfset navList = arrayToList(xmlSearch(xmlParse(myXML), "//navItem/name/string()"), "^")>
<cfset navList = arrayToList(xmlSearch(xmlParse(myXML), "//navItem/name/string()"), "^")>