domDocumet を使用した非常に単純なコードがありますが、解決できない間違いがあります。
function getTagXML($mensaje, $tagname){
$dom = new domDocument('1.0', 'UTF-8');
libxml_use_internal_errors(true);
// load the html into the object ***/
$dom->loadHTML($mensaje);
//discard white space
$dom->preserveWhiteSpace = false;
$nodeList= $dom->getElementsByTagName($tagname); // here u use your desired tag
$node = $nodeList->item(0);
$item = trim($node->nodeValue);
libxml_clear_errors();
return $item;
}
エラーが発生しました:
Notice: Trying to get property of non-object in line 82:
82 行目:
$item = trim($node->nodeValue);