ID: 14340 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Closed Bug Type: DOM XML related Operating System: Linux Debian Woody PHP Version: 4.1.0 New Comment:
ok i modified the $node->name in $node->tagname the script: -------------------------------------------- <? $string = "<?xml version=\"1.0\"?> <webcam_users> <user> <login>user1</login> <password>passwd1</password> </user> <user> <login>user2</login> <password>passwd2</password> </user> <user> <login>guest</login> <password>guest_passwd</password> </user> </webcam_users>"; $doc = xmldoc($string); $root = domxml_root($doc); $users = domxml_children($root); foreach ($users as $user){ if ($user->type == "1") { $nom = $user->tagname; print "balise: ".$nom."<BR>"; print_r($user);} } function find_content($parent,$name){ $nodes = $parent->children(); while($node = array_shift($nodes)) { if ($node->tagname == $name){ return get_content($node); } } return ""; } ?> -------------------------------------------------- the result with PHP4.1RC1 /libxml2 v2.4.8: NOTHING! -------------------------------------------------- with PHP4.0.6 / libxml2 v2.4.5: balise: DomNode Object ( [name] => user [content] => user1 passwd1 [node] => Resource id #4 [type] => 1 ) balise: DomNode Object ( [name] => user [content] => user2 passwd2 [node] => Resource id #6 [type] => 1 ) balise: DomNode Object ( [name] => user [content] => guest guest_passwd [node] => Resource id #8 [type] = > 1 ) -------------------------------------------------- Before trying DOMXML, i downloaded latest PHP manual ... but ... help me I'm lost I don't underdstand... as you say $node->tagname should work ... if so, why do I have no output ??? If it's not a bug, what is the correct syntax? Please can you correct my script? (sorry, I'm aware that I make you loose your time) Thanks a lot! Previous Comments: ------------------------------------------------------------------------ [2001-12-04 20:58:18] [EMAIL PROTECTED] As i said, its not 'name' in this case but 'tagname'. This is the behaviour now. Not a bug, closing. ------------------------------------------------------------------------ [2001-12-04 15:24:19] [EMAIL PROTECTED] and the problem is the same under Debian Sid (unstable) /php4.1RC1 / libxml2 2.4.8 ------------------------------------------------------------------------ [2001-12-04 15:23:05] [EMAIL PROTECTED] print_r($xmlstring) works well, tough. an example code: _____________________________________________________ <? $string = "<?xml version=\"1.0\"?> <webcam_users> <user> <login>user1</login> <password>passwd1</password> </user> <user> <login>user2</login> <password>passwd2</password> </user> <user> <login>guest</login> <password>guest_passwd</password> </user> </webcam_users>"; $doc = xmldoc($string); $root = domxml_root($doc); $users = domxml_children($root); foreach ($users as $user){ if ($user->type == "1") { $nom = $user-> name; print "balise: ".$nom."<BR>";} } function find_content($parent,$name){ $nodes = $parent->children(); while($node = array_shift($nodes)) { if ($node->name == $name){ return get_content($node); } } ?> _______________________________________________ This code returns: ________________________________________ balise: user balise: user balise: user ___________________________________________ with php4.0.6 /libxml2 2.4.5 and nothing with php4.1RC1 / libxml2 2.4.8 ------------------------------------------------------------------------ [2001-12-04 13:06:03] [EMAIL PROTECTED] Wtf? Sorry, feedback. ------------------------------------------------------------------------ [2001-12-04 13:05:46] [EMAIL PROTECTED] A sample script would help very much. I think what you are searching for is actually 'tagname'. If you're unsure, just try a print_r($domobjnode); and see its properties. Feedback. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/?id=14340 Edit this bug report at http://bugs.php.net/?id=14340&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]