我正在使用GDataXML (在后台使用 libxml2)在 iPhone 上从 XML 文件读取名称列表。
<persons>
<person id=1>
<firstname>John<firstname>
<lastname>Doe<lastname>
</person>
</persons>
但是当我尝试将名字和姓氏与
连接时/persons/person/concat(firstname, ' ', lastname)
它不适用于 GDataXML。当使用 .NET XML 库尝试相同的示例或使用 AquaPath 进行测试时,它可以工作。
有任何提示或其他替代方法可以使其正常工作吗?
最佳答案
But when i try to concat first and lastname with
/persons/person/concat(firstname, ' ', lastname)
it doesn't work with GDataXML.
LibXML 仅实现 XPath 1.0。
上述表达式在 XPath 1.0 中语法不正确(它是正确的 XPath 2.0 表达式)。
When trying the same with example with the .NET XML libary or testing it with AquaPath it works.
您对 .NET XML 的看法是错误的(除非您使用第三方 XPath 2.0 处理器,例如 Saxon、Altova 或 XQSharp)--.NET 不实现 XPath 2.0强>.
解决方案:
使用以下 XPath 1.0 表达式:
concat(/*/*/firstname, ' ', /*/*/lastname)
关于iphone - GDataXML/Libxml2 XPath concat 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4287805/