Ricalsin
Ricalsin

Reputation: 940

Perl XPath to the value of a form input field

Shortened example of some html:

<input name="some_name" id="some_ID" value="The-Value-I-Want" />

In Perl,

//input[contains(@id, 'some')]/@value

Gives me:

value="The-Value-I-Want"

But all I REALLY want is :

"The-Value-I-Want"

I would have thought:

//input[contains(@id, 'some')]/@value/text

would have done it - but no. I've tried /@value[text] , /@value/@text , /@value/text() , etc

All the help I find on this issue is in Javascript XPath (or other). Perl is my language.

Thanks for any help! :)

Upvotes: 1

Views: 460

Answers (1)

daxim
daxim

Reputation: 39158

string(//input[contains(@id, 'some')]/@value)

Tested with libxml2. See http://www.w3.org/TR/xpath/#function-string

Upvotes: 4

Related Questions