gpt4 book ai didi

iphone - 如何使用 XPath 获取根元素?

转载 作者:搜寻专家 更新时间:2023-10-30 20:12:53 35 4
gpt4 key购买 nike

这是我的 XML 文档:

<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>

我只想获取根文件元素。我在 iPhone 上使用 TouchXML,这是我的 xPath 查询:

/container/rootfiles/rootfile

没用!我什么都试过了。

最佳答案

container 节点中的 xmlns 位是一个 namespace 前缀,您可以将其查询注册。

我不太了解 TouchXML,无法说明解决方案是什么,但相关的 libxml2 调用是 xmlXPathRegisterNs()如果您深入了解 TouchXML 的内部结构。

SO answer也可能会帮助您找到正确的 TouchXML 方法来注册此命名空间。

关于iphone - 如何使用 XPath 获取根元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2748075/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com