|
xml2Array
This class is in functions.inc.php.
Example use:
$str = <<<EOF <test> <foo>this is foo</foo> <bar attr1="123" attr2="456">this is bar</bar> <names> <name>Bob</name> <name>Fred</name> <name>Tom</name> </names> <people> <unknown>Jesse</unknown> <female>Mary</female> <female>Pam</female> <female height="1.6">Sara</female> <male weight="80" height="1.8">Joe</male> <male height="1.7">Albert</male> <male /> </people> </test> EOF; $xml = new xml2Array($str); echo "xml->data: \n"; print_r($xml->data); echo "xml->attributes: \n"; print_r($xml->attributes);
Output:
xml->data:
Array
(
[test] => Array
(
[foo] => this is foo
[bar] => this is bar
[names] => Array
(
[name] => Array
(
[0] => Bob
[1] => Fred
[2] => Tom
)
)
[people] => Array
(
[unknown] => Jesse
[female] => Array
(
[0] => Mary
[1] => Pam
[2] => Sara
)
[male] => Array
(
[0] => Joe
[1] => Albert
[2] =>
)
)
)
)
xml->attributes:
Array
(
[/test/bar] => Array
(
[attr1] => 123
[attr2] => 456
)
[/test/people/female/2] => Array
(
[height] => 1.6
)
[/test/people/male/0] => Array
(
[weight] => 80
[height] => 1.8
)
[/test/people/male/1] => Array
(
[height] => 1.7
)
)
