Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下 XML 文件:
<ns1:book> <ns1:title>Harry Potter</ns1:title> <ns1:author>Rowling</ns1:author> </ns1:book>
在 XPath-query 的帮助下,我只想获取 teg 的内容<title>,这里是Harry Potter(不是<ns1:title>Harry Potter</ns1:title>)。我怎样才能做到这一点?它有什么功能吗?
<title>
Harry Potter
<ns1:title>Harry Potter</ns1:title>
/text()在找到元素后使用。
/text()
像://*[name()='ns1:title']/text()
//*[name()='ns1:title']/text()
请参阅此处的示例..
另一种语法(虽然不确定每个 XPath 处理器都支持它):
//*:title/text()