Is it possible using xpath request to pull 2 ​​attributes of each element that satisfy the conditions of the request? Suppose id and value, roughly speaking, to get an array whose elements are arrays of two values. If so, how?

  • So java or python? In the header one, in the tag - the other. However, for xpath it is not important. - Alexander Petrov
  • Use operator | - or . - Alexander Petrov
  • Specify what you want, more specifically, please. - nick_gabpe
  • @nick_gabpe I want to get the attributes of the elements. each element has 2 attributes in one request I want to get the values ​​of these attributes, so that I know who this attribute belongs to; obtaining the element itself does not fit - ddsds

1 answer 1

Use | - union operator.

For example, there is an xml of the form:

 <nodes> <node id="1" value="foo" /> <node id="2" value="bar" /> </nodes> 

The XPath to get the id and value attributes might look like this:

 "//node/@id | //node/@value"