I'm trying to get the value of a hidden form with xpath, there are several input fields
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the page
$x = new DOMXPath($dom);
$nodes = $x->query('/html/body/div/div[4]/div[2]/input');
foreach ($nodes as $node) {
echo $name1 = $node->getValue;
}
this is the HTML code:
<input type="hidden" value="1199" name="year">
Simply put @value
at the end of your query.
use:
/html/body/div/div[4]/div[2]/input[@name='year']/@value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With