Let’s say I have this code:
$dom = new DOMDocument();
@$dom->loadHTMLFile('sample.html');
$xp = new DOMXPath($dom);
$result = $xp->query("//input[@id='honey']");
How do I get the content of the attribute value of the first result only, since I’m only expecting one result (without using a foreach loop). I tried var_dump-ing the result but it can’t. I also tried current($result)->getAttribute('value') but not luck.
You can access it via the following method: