PHP DOMDocument getElementsByTagname?

前端 未结 2 1719
耶瑟儿~
耶瑟儿~ 2020-12-17 18:21

This is driving me bonkers... I just want to add another img node.

$xml = <<


        
2条回答
  •  余生分开走
    2020-12-17 18:57

    DOMDocument::getElementsByTagName doesn't return an array, it returns a DOMNodeList. You need to use the item method to access its items:

    $album = $xmlDoc->getElementsByTagname('album')->item(0);
    

提交回复
热议问题