I have a piece of HTML code:
<form method="post" action="/"> <input type="hidden" name="example-name" value="example-value"> <button type="submit">Submit</button> </form>
How can I extract hidden input value using DOMXPath in PHP? I tried something like this:
//$site - the html code $doc = new DOMDocument(); $doc->loadHTML($site); $xpath = new DOMXpath($doc); $kod = $xpath->query("//input[@name='example-name']"); foreach($kod as $node) $values[]=$node->nodeValue; return $values;
But it returns an empty array. Where is the mistake?
source share