How to define an xpath to an attribute’s value
Say for example we are looking at the following code and trying to pick out the emboldened text in one xpath query. (i.e The string value of the action attribute)
<form name=”MyForm” method=”post” action=”newpage.php” id=”MyForm”>
I have tried the following xpaths , but they don’t work
$xpath= '//form[contains(@name="MyForm"]/@action/value()';
and
$xpath= '//form[contains(@name="MyForm"]/@action/text()';
and I tried
$xpath= ‘//form[contains(@name=”MyForm”]/@action/string(@value)’;
…any help?
P.S The suggestion here, doesn’t seem to work either - i think it assumes that we have already got a node to apply the string () function on.