XQuery: Access value in node

Viewed 41

I have text-input-boxes on a website which I´m accessing via XQuery. Something like this on the website:

<input id="input1" type="text" value="300">

I need to access the "value" fields, but I´m missing the idea here how to do this.

Here´s the code I´ve tried:

let $doc := html:parse(fetch:binary('websiteaddress'))
return
<datarow>
<input1>{data($doc/html/body/div/div/div/div/div)}
</input1>
</datarow>

As result I get all the description text on the website, but not the fields itself.

At the end I would need datarows with the "value". So I guess I have to do something like $doc//div[@id="input1"]?....but how to access the value?

Any ideas on that?

1 Answers

You can access the attribute values with the attribute axis.

Most people use the abbreviated syntax @:

$doc//input[@id="input1"]/@value

but you can also use attribute:::

$doc//input[@id="input1"]/attribute::value
Related