Parser XML with PHP:
$xml_string = "<?xml version='1.0'?>
<users>
<user id='2' status='Admin'>
<username>Mikki Mau</username>
<useremail>mikki@mydomain.com</useremail>
</user>
<user id='3' status='User'>
<username>Miki Mau</username>
<useremail>mikki@mydomain.com</useremail>
</user>
</users>";
$xml = simplexml_load_string($xml_string);
foreach ($xml->user as $user) {
//Get "id" and "status" attributes
echo $user['id'].' ('.$user['status'].')<br>';
//Get subnodes
echo $user->username. '<br>';
echo $user->useremail. '<br>';
}
Комментариев нет:
Отправить комментарий