note 45090 deleted from function.domelement-get-attribute-node by aidan
| From: | aidan@php.net | Date: | Thu, 26 Aug 2004 06:25:35 +0000 |
| Subject: | note 45090 deleted from function.domelement-get-attribute-node by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75278@lists.php.net to get a copy of this message | ||
Note Submitter: david0733 at hotmail dot com
----
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!!!