Hi all,
Should I be using another Class to parse my XML?
I've been trying to use XMLReader to get the info I need from the XML but it seems to duplicate the result. I suspect it finds
<User ...> and finds the attribute within... then gets to
</User> and looks for the attribute
again!
Here is a sample of the XML
Code:
<?xml version="1.0"?>
<Users>
<User LoginName="jdoe" Alias="John Doe">
<Contact Name="John Doe" Email="jdoe@home.com"/>
</User>
...
</Users>
Here is a sample of my php script to extract the
LoginName
PHP Code:
Class Parse
{
public function ListAllUserLogins($xml)
{
$reader = new XMLReader();
$reader->XML($xml);
$i=0;
While ($reader->read())
{
echo "$i ";
if ($reader->localName == "User")
{
echo "$reader->localName: ";
$login = $reader->getAttribute("LoginName");
if ($login != "")
{
echo "$login\n";
} else {
echo "EMPTY\n";
}
} else {
echo "WRONG Local Name: $reader->localName\n";
}
$i++;
}
$reader->close();
}
}
- The echo are to debug...
- Any improvements to the above are welcome... I'm a newb

The output
Code:
0 WRONG Local Name: Users
1 User: jdoe
2 WRONG Local Name: Contact
3 User: jdoe
jdoe is found twice!
Can you help me get rid of the duplicate result?
Thanks