S
S
serega 20702021-01-21 16:24:56
XPath
serega 2070, 2021-01-21 16:24:56

How to get to the content of the data attribute of the input tag?

Hello, tell me pliz
, here is the xpath trying to take the contents of the data-sell from the input

//input[@data-currency='USD']/@data-buy

with such a request gives


data-buy="74.19"
data-buy="74.19"
data-buy="74.19"


and I need first the first input and I don’t need only the content of the data attribute without the attribute itself, that is:

74.19

not completely
data-buy="74.19"


on the page this code
<input type="hidden" data-currency="USD" data-sell="78" data-buy="74.19">
<input type="hidden" data-currency="USD" data-sell="78" data-buy="74.19">
<input type="hidden" data-currency="USD" data-sell="78" data-buy="74.19">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-01-21
@glebovgin

First element, as it should be:
//input[@data-currency='USD'][1]
To return a value, I think it will do:
string(//input[@data-currency='USD'][1]/@data-buy)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question