title: PHP DOMXPath query using the innerHTML/nodeValue of an element to find and return the element
body: <p>Can you please help me with the correct syntax to use when you want to check the innerHTML/nodeValue of an element?</p>
  
  <p>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.</p>
  
  <p>$html is a page from the internet</p>
  
  <p>The persons name is in a span like:</p>
  
  <pre><code>&lt;span class="fullname"&gt;John Smith&lt;/span&gt;
  </code></pre>
  
  <p>The persons age is in a div like:</p>
  
  <pre><code>&lt;div&gt;Age: 28&lt;/div&gt;
  </code></pre>
  
  <p>I have the following PHP:</p>
  
  <pre><code>&lt;?php
  $dom = new DomDocument();
  @$dom-&gt;loadHTML($html);
  $finder = new DOMXPath($dom);
  
  //Full Name
  $findName = "fullname";
  $queryName = $finder-&gt;query("//span[contains(@class, '$findName')]");
  $name = $queryName-&gt;item(0)-&gt;nodeValue;
  
  //Age
  $findAge = "Age: ";
  $queryAge = $finder-&gt;query("//div[NOT SURE WHAT TO PUT HERE]");
  $age = substr($queryAge-&gt;item(0)-&gt;nodeValue, 5);
  ?&gt;
  </code></pre>