XML php help

Having some problems with XML
Im knew to it and trying to get a file to read properly
basicly im trying to get it to work like mysql_fetch_array command
I want to take some info out of the XML file and have it displayed in a table
Here is what i have now and im sure its wrong


<?php

// set name of XML file
$file = "acc.xml";

// load file
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");

// access XML data
echo "<table border='1'>";
echo "<tr>";
echo "<td><b>Username</b></td>";
echo "<td><b>IP</b></td>";
echo "</tr>";

foreach ($xml->xpath('//username') as $username) {
echo "<tr><td>$username\n</td></tr>";

echo "</td></tr>";
}

foreach ($xml->xpath('//ip') as $ip) {
echo "<tr><td>$ip\n</td></tr>";
}

echo "</table>";

?>


what is the proper command or set of commands to do that?Looks reasonable.
im sure its wrongYou mean you can't tell?well that script works well but it doenst array it properly in the table.. For example i want all the uernames in one column along with the ips in another..
That script that i posted doesnt do that.
Any ideas?Ah, well, that's because that's what you're telling it to do. Rows of all the usernames followed by rows of all the IPs.
Me, I'd read both lists of results into arrays, and then go through both concurrently with a for() loop.Ya i have it kinda working the way i want but not fully. Basicly I want each row to display an account.
so my table should look like this
User ID | IP | Last connect | Total Connect|

I can get the user id to display and even the IP but the problem is it list each IP in a new colum instead of how they should be listed (some users have more then 1 IP) So in that case i want all those IP's to show in 1 column

I think its the command that im using to parse the info is the wrong one.. Any clues ideas or websites you can refer me to.
I found this one but for some reason the code is incorrect and im having a hard time finding the errors
<!-- m --><a class="postlink" href="http://www.zend.com/zend/tut/tutbarlach.php">http://www.zend.com/zend/tut/tutbarlach.php</a><!-- m -->

that example there is almost like what im trying to do but i dont need the href links..
 
Back
Top