note 45090 added to function.domelement-get-attribute-node

From: Date: Thu, 26 Aug 2004 01:48:45 +0000
Subject: note 45090 added to function.domelement-get-attribute-node
Groups: php.notes 
Request: Send a blank email to php-notes+get-75273@lists.php.net to get a copy of this message
y depi gay!!! 04-Mar-2003 07:00 Is common try to get an attribute of an DomElement object type, and this object don't be DomElement type. This problem exist because when u try to list the count of children of a node, by DomNode->child_nodes() function, it give u DomElements and DomTexts objects. I think that this is bad... To resolve it problem, before u apply DomElement->get_attribute_node() function, u must be sure that this DomElement object type is really a DomElement and don't be a DomText object type. U can use this code to resolve it: /* count childs */ $child_count=$root->child_nodes(); //echo "I have ".$child_count." childs<BR>"; /* Array of childs */ $childs=$parent_element->child_nodes(); for( $i = 0 ; $i < $child_count ; $i++){ $var_attribute=$childs[$i]->attributes(); /* Now i verify if $childs[$i] is a DomElement or a DomText object type */ if( $var_attribute == NULL ){ /* Don't be a DomElement , it is a DomText object type */ continue; } /* Now $childs[$i] is a DomElement object type and u can use DomElement->get_attribute_node() function */ //var_dump($var_attribute); } Good Luck. y depi gay!!! y depi gay!!! ---- Manual Page -- http://www.php.net/manual/en/function.domelement-get-attribute-node.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45090 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45090&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45090&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75273) next »