XPath string(/ROOT/Products/UnitPrice)
在 dom4j 和 .NET 运行时中运行良好。但在撒克逊语中它会抛出一个异常:
net.sf.saxon.s9api.SaxonApiException: A sequence of more than one item is not allowed as the first argument of string() (<UnitPrice/>, <UnitPrice/>, ...)
这是怎么回事?为什么这样不行?
最佳答案
Saxon 期望单个节点作为输入。
.NET 实现不同;它只考虑第一个:
The string() function converts a node-set to a string by returning the string value of the first node in the node-set, which in some instances may yield unexpected results.
参见MSDN
关于java - 如何获取节点的字符串值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50787050/