0

我有以下 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>)。我怎样才能做到这一点?它有什么功能吗?

4

2 回答 2

2

/text()在找到元素后使用。

像://*[name()='ns1:title']/text()

请参阅此处的示例..

于 2020-04-30T13:01:51.510 回答
0

另一种语法(虽然不确定每个 XPath 处理器都支持它):

//*:title/text()
于 2020-04-30T13:46:05.853 回答