I have the following XML-file:
<ns1:book> <ns1:title>Harry Potter</ns1:title> <ns1:author>Rowling</ns1:author> </ns1:book>
With the help of XPath-query I want to get only content of teg <title>
, here it is Harry Potter
(not <ns1:title>Harry Potter</ns1:title>
). How can I do this? Is there any function for it?
Use /text()
after you have located an element.
Like: //*[name()='ns1:title']/text()
See the example here ..
Another syntax (not sure every XPath processor supports it though):
//*:title/text()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.