note 18838 added to function.domxml-children
| From: | ken at positive-edge dot com | Date: | Thu, 07 Feb 2002 02:53:04 +0000 |
| Subject: | note 18838 added to function.domxml-children | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26326@lists.php.net to get a copy of this message | ||
I'm going to tell you a much better solution to the above white space issue.
Do you really want to edit a 800k or even an 800 meg XML file to fix the white space? Probably
not. Sorry mux space.
Every node has a member called 'name', which will tell you the element's name. Since
text nodes don't have an element name (they simply return as 'text'), you can safely
avoid these. Here is an example
function findApplicationNode( $root, $applicationName ) {
$applications = $root->children();
foreach( $applications as $applicationNode ) {
if( $applicationNode->name == 'application' ) {
if( $applicationNode->getattr( 'name' ) == $applicationName ) {
return $applicationNode;
}
}
}
}
Notice as I iterate through each node, I check the node's name field to see if it equals the
desired element name using the code: if( $applicationNode->name == 'application' )..
Ken Egervari, Positive Edge
--
http://www.php.net/manual/en/function.domxml-children.php
http://master.php.net/manage/user-notes.php?action=edit+18838
http://master.php.net/manage/user-notes.php?action=delete+18838
http://master.php.net/manage/user-notes.php?action=reject+18838