<?php
require_once('xml2array.php');
$xml = '<books><book><title>C programming</title><author rating="3">Balaguruswamy</author></book><book><title>Bookname1</title><author rating="5">Vineet</author></book></books>';
$converter = new Xml2Array();
$converter->setXml($xml);
$xml_array = $converter->get_array();
print_r($xml_array);
/*
* Array
(
[books] => Array
(
[book] => Array
(
[0] => Array
(
[title] => Array
(
[#text] => C programming
)
[author] => Array
(
[#text] => Balaguruswamy
[@rating] => 3
)
)
[1] => Array
(
[title] => Array
(
[#text] => Bookname1
)
[author] => Array
(
[#text] => Vineet
[@rating] => 5
)
)
)
)
)
*
*/
?>
|