Can you please help me with the correct syntax to use when you want to check the innerHTML/nodeValue of an element?
I have no problem with the Name however the Age is within a plain div element, What is the correct syntax to use in place of "NOT SURE WHAT TO PUT HERE" below.
$html is a page from the internet
The persons name is in a span like:
<span class="fullname">John Smith</span>
The persons age is in a div like:
<div>Age: 28</div>
I have the following PHP:
<?php
$dom = new DomDocument();
@$dom->loadHTML($html);
$finder = new DOMXPath($dom);
//Full Name
$findName = "fullname";
$queryName = $finder->query("//span[contains(@class, '$findName')]");
$name = $queryName->item(0)->nodeValue;
//Age
$findAge = "Age: ";
$queryAge = $finder->query("//div[NOT SURE WHAT TO PUT HERE]");
$age = substr($queryAge->item(0)->nodeValue, 5);
?>