Cannot access attribute value using xpath

I cannot get the value of the second attribute based on the first attribute. I am trying to get the value of the content attribute. those. 4,450from the following XML:

<meta itemprop="price" content=" 4,450" />

Tried XPath with this: //meta[@itemprop=\"price\"][@content] But I get output similar to input XML.

+4
source share
2 answers

An attribute contentrequires a slash:

//meta[@itemprop='price']/@content
+3
source

Usage is incorrect.

Use the following code

//meta[@itemprop=\"price\"]/@content
+3
source

Source: https://habr.com/ru/post/1546091/


All Articles