user3587233
user3587233

Reputation: 263

How to access individual values using Xpath?

The following xpath that I have returns 3 table items and I would like to access each value individually.

//div[@class='transform section']//div[@class='inner-border-section-gray-container']//div[@class='related-tables-section']//div[@class='inner-section']//span[@class='related-tables']

enter image description here

How can I access "customer", "lineitem" and "orders" individually using xpath?

Can someone please help with the above?

Upvotes: 0

Views: 41

Answers (2)

har07
har07

Reputation: 89285

You can try using /text() to get text nodes that is direct child of the <span> :

//span[@class='related-tables']/text()

you may want to add condition to filter out empty text nodes :

//span[@class='related-tables']/text()[normalize-space()]

Upvotes: 1

Anthony Mason
Anthony Mason

Reputation: 175

Is it possible for you to supply them individually with a surrounding element? Then you could use the data attribute, if using Razer syntax you must say data_myVariable="something" otherwise replace the "_" with a "-" and you can then access the data attribute using data-myVariable.

Upvotes: 0

Related Questions