Re: about domxml api-change in 4.0.7
| From: | Colin Viebrock | Date: | Mon, 20 Aug 2001 14:51:18 +0000 |
| Subject: | Re: about domxml api-change in 4.0.7 | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-63847@lists.php.net to get a copy of this message | ||
FWIW, I've needed to hack my code to handle three differences between the 2
different API versions. To be honest, I can't keep track of which API was
in which release of PHP, so I'll just call them API A) and API B).
1) Names of tags:
API A) $node->name
API B) $node->tagname
2) Tag attribute value:
API A) $node->children[0]->content
API B) $node->value
3) Is a node a text node:
API A) $node->type == XML_TEXT_NODE
API B) strtolower(get_class($node)) == 'domtext'
I haven't installed libxml 2.4.2 and PHP 4.0.7rc1 yet, but I'm wondering if
someone can tell me which API version is in use? This script should tell
you:
<?php
$__x = xmltree('<a b="c">d</a>');
if ($__x->children[0]->name=='a' &&
$__x->children[0]->attributes[0]->name=='b' &&
$__x->children[0]->attributes[0]->children[0]->content=='c' &&
$__x->children[0]->content=='d') {
echo 'API A';
} else if ($__x->children[0]->tagname=='a' &&
$__x->children[0]->attributes[0]->name=='b' &&
$__x->children[0]->attributes[0]->value=='c' &&
$__x->children[0]->children[0]->content=='d') {
echo 'API B';
} else {
echo 'something totally new :(';
}
- Colin