Skip to main content

I have the following xml and want to get the attribute (identifier='content')(identifier='content') value for the attribute (identifier='id')(identifier='id') with idid 510 with the help of xpath.

<product id='1'> <row='1'> <attribute identifier='id'>510</attribute> <attribute identifier='content'>Test 1</attribute> </row> <row='2'> <attribute identifier='id'>100</attribute> <attribute identifier='content'>Test 2</attribute> </row> ... </product> 

I tried it with:

//product[@id='1']/row/attribute[@identifier='id' and text()='510'] 

But as I already know this returns me only the content of the attribute with identifier='id'identifier='id'. How to gehtget the value of identifier='content'identifier='content' where identifier 'id'= 510'id'= 510?

Thanks for any help.

I have the following xml and want to get the attribute (identifier='content') value for the attribute (identifier='id') with id 510 with the help of xpath.

<product id='1'> <row='1'> <attribute identifier='id'>510</attribute> <attribute identifier='content'>Test 1</attribute> </row> <row='2'> <attribute identifier='id'>100</attribute> <attribute identifier='content'>Test 2</attribute> </row> ... </product> 

I tried it with:

//product[@id='1']/row/attribute[@identifier='id' and text()='510'] 

But as I already know this returns me only the content of the attribute with identifier='id'. How to geht the value of identifier='content' where identifier 'id'= 510?

Thanks for any help.

I have the following xml and want to get the attribute (identifier='content') value for the attribute (identifier='id') with id 510 with the help of xpath.

<product id='1'> <row='1'> <attribute identifier='id'>510</attribute> <attribute identifier='content'>Test 1</attribute> </row> <row='2'> <attribute identifier='id'>100</attribute> <attribute identifier='content'>Test 2</attribute> </row> ... </product> 

I tried it with:

product[@id='1']/row/attribute[@identifier='id' and text()='510'] 

But as I already know this returns only the content of the attribute with identifier='id'. How to get the value of identifier='content' where identifier 'id'= 510?

Thanks for any help.

Source Link
frgtv10
  • 5.5k
  • 4
  • 33
  • 47

Xpath Get value of current node

I have the following xml and want to get the attribute (identifier='content') value for the attribute (identifier='id') with id 510 with the help of xpath.

<product id='1'> <row='1'> <attribute identifier='id'>510</attribute> <attribute identifier='content'>Test 1</attribute> </row> <row='2'> <attribute identifier='id'>100</attribute> <attribute identifier='content'>Test 2</attribute> </row> ... </product> 

I tried it with:

//product[@id='1']/row/attribute[@identifier='id' and text()='510'] 

But as I already know this returns me only the content of the attribute with identifier='id'. How to geht the value of identifier='content' where identifier 'id'= 510?

Thanks for any help.