Fatal error: Call to undefined method DOMNodeList::getElemen

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kendhal
Forum Newbie
Posts: 3
Joined: Thu Apr 24, 2008 4:27 pm

Fatal error: Call to undefined method DOMNodeList::getElemen

Post by kendhal »

Folks,
This is driving me crazy. I have PHP5.2.6 running on linux and have DOM enabled as shown below in my phpinfo call:
DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.6.32
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled

The simple PHP code below gives me the following error:
"Fatal error: Call to undefined method DOMNodeList::getElementsByTagName()"

$dom = new DomDocument();
$dom->load("articles.xml");
$titles = $dom->getElementsByTagName("title");
foreach($titles as $node) {
print $node->textContent . " ";
}

Can anyone shed some light on this? Thanks a ton.

KD
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Fatal error: Call to undefined method DOMNodeList::getElemen

Post by Jade »

Isn't it getElementByTagName? I think you have a typo. Or you could always try getElementbyID instead.
visu
Forum Newbie
Posts: 4
Joined: Fri Jun 06, 2008 2:48 pm

Re: Fatal error: Call to undefined method DOMNodeList::getElemen

Post by visu »

Hi.

Try $dom->documentElement->getElementsByTagName() instead of $dom->getElementsByTagName()
Post Reply