Hi :)
You can find a fully working code down here.
It does not only works with the tagname problem but it also solves the
displaying of contents.
Right now only the textnode has a 'content' property.
<?
$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);
if (false == $doc)
{
die('The input XML is bad formed');
}
$root = $doc->root();
$users = $root->children();
foreach ($users as $user)
{
if ($user->type == "1")
{
file://$nom = $user->tagname;
file://print "balise: ".$nom."<BR>";
$login=find_content($user, 'login');
if (false != $login)
{
echo 'Login: '.$login;
}
echo '<br/>';
$pazz=find_content($user, 'password');
if (false != $login)
{
echo 'Pazz: '.$pazz;
}
echo '<br/>';
}
}
function find_content($parent,$name)
{
$nodes = $parent->children();
while($node = array_shift($nodes))
{
if ($node->tagname == $name)
{
return get_content($node);
}
}
return false;
}
function get_content($domElement)
{
$children=$domElement->children();
return $children[0]->content;
}
?>
--
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]