title: Undefined property: DOMElement::$wholeText
body: <p>I'm getting the following error: <code>Undefined property: DOMElement::$wholeText"</code> when I loop over the query and try to echo the wholeText result.</p>
  
  <pre><code>$try = $xpath-&gt;query('//h2/following-sibling::ul/li | //h2/following-sibling::h3/text()');
  
  foreach($try as $values){
      echo $values-&gt;wholeText;    
  
      //echo '&lt;pre&gt;', print_r($values), '&lt;/pre&gt;';
  }
  </code></pre>
  
  <p>The <code>$xpath-&gt;query</code> returns the following when I <code>print_r</code> the <code>$values</code> variable from the foreach.</p>
  
  <pre><code>DOMText Object {
      [wholeText] =&gt; House Data
      [data] =&gt; House Data
      [length] =&gt; 10
      [nodeName] =&gt; #text
      [nodeValue] =&gt; House Data
      [nodeType] =&gt; 3
      [parentNode] =&gt; (object value omitted)
      [childNodes] =&gt; 
      [firstChild] =&gt; 
      [lastChild] =&gt; 
      [previousSibling] =&gt; 
      [nextSibling] =&gt; 
      [attributes] =&gt; 
      [ownerDocument] =&gt; (object value omitted)
      [namespaceURI] =&gt; 
      [prefix] =&gt; 
      [localName] =&gt; 
      [baseURI] =&gt; 
      [textContent] =&gt; House Data
  )
  
  DOMElement Object (
      [tagName] =&gt; li
      [schemaTypeInfo] =&gt; 
      [nodeName] =&gt; li
      [nodeValue] =&gt; 12 doors are very expensive
      [nodeType] =&gt; 1
      [parentNode] =&gt; (object value omitted)
      [childNodes] =&gt; (object value omitted)
      [firstChild] =&gt; (object value omitted)
      [lastChild] =&gt; (object value omitted)
      [previousSibling] =&gt; 
      [nextSibling] =&gt; (object value omitted)
      [attributes] =&gt; (object value omitted)
      [ownerDocument] =&gt; (object value omitted)
      [namespaceURI] =&gt; 
      [prefix] =&gt; 
      [localName] =&gt; li
      [baseURI] =&gt; 
      [textContent] =&gt; 12 doors are very expensive
  )
  
  DOMText Object (
      [wholeText] =&gt; Car Data
      [data] =&gt; Car Data
      [length] =&gt; 8
      [nodeName] =&gt; #text
      [nodeValue] =&gt; Car Data
      [nodeType] =&gt; 3
      [parentNode] =&gt; (object value omitted)
      [childNodes] =&gt; 
      [firstChild] =&gt; 
      [lastChild] =&gt; 
      [previousSibling] =&gt; 
      [nextSibling] =&gt; 
      [attributes] =&gt; 
      [ownerDocument] =&gt; (object value omitted)
      [namespaceURI] =&gt; 
      [prefix] =&gt; 
      [localName] =&gt; 
      [baseURI] =&gt; 
      [textContent] =&gt; Car Data
  )
  
  DOMElement Object (
      [tagName] =&gt; li
      [schemaTypeInfo] =&gt; 
      [nodeName] =&gt; li
      [nodeValue] =&gt; The car has 4 doors
      [nodeType] =&gt; 1
      [parentNode] =&gt; (object value omitted)
      [childNodes] =&gt; (object value omitted)
      [firstChild] =&gt; (object value omitted)
      [lastChild] =&gt; (object value omitted)
      [previousSibling] =&gt; 
      [nextSibling] =&gt; (object value omitted)
      [attributes] =&gt; (object value omitted)
      [ownerDocument] =&gt; (object value omitted)
      [namespaceURI] =&gt; 
      [prefix] =&gt; 
      [localName] =&gt; li
      [baseURI] =&gt; 
      [textContent] =&gt; The car has 4 doors
  )
  </code></pre>
  
  <p>But if I <code>echo $values-&gt;nodeValue;</code> it works, although it echo's all of the data, I'm just trying to access the wholeText individually, I don't understand why this error is popping up?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Now that I took a closer look, I see that when I <code>echo $values-&gt;wholeText;</code> it's trying to echo the DOMElement and not the DOMText.</p>
  
  <p>How can I reference the DOMText instead of the DOMElement when echoing?</p>