title: PHP: extra content at the end of the document in entity, trying to extract the nodeValue
body: <pre><code>&lt;?php
  
  echo getValue('&lt;a&gt;dk&lt;/a&gt;&lt;b&gt;sh&lt;/b&gt;', 'a');
  
  function getValue($string, $tagname) {
      $dom = new DomDocument();
      $dom-&gt;loadXML($string);
      $node_list = $dom-&gt;getElementsByTagName($tagname)-&gt;item(0);
      return $node_list-&gt;nodeValue;
  }
  </code></pre>
  
  <p>running the script returns</p>
  
  <pre><code>Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 1 in /Users/johnkim/get.php on line 7
  </code></pre>