I have the following xml file (sample)
<xml>
<product>
<url>banners</url>
<name>Banners</name>
</product>
<product>
<url>billboards</url>
<name>Billboards</name>
</product>
<product>
<url>brochures</url>
<name>Brochures</name>
</product>
<product>
<url>business-cards</url>
<name>Business Cards</name>
</product>
</xml>
and I want to write a PHP script that when parsing the xml file (which changes now and then and not going to be manually sorted) sorts the values alphabetically by the tag, but the code I have found to convert my xml file to an array puts a lot of useless information in the array as well and makes it near impossible to sort and display the information I want displayed. here is the php code i have so far
<?php
$file = file_get_contents("xml/products.xml");
$p = xml_parser_create();
xml_parse_into_struct($p, $file, $vals, $index);
xml_parser_free($p);
asort($vals['value']);
echo "<H1>Vals array</H1><BR>";
print_r($vals);
?>
is there another way to convert my xml file without all the unnecessary information as well and in such a way that I can easily display the information afterwords??
the array I hope to end up with will look like
Array
(
[product] => Array
(
[url] => window-clings
[name] => Window Clings
)
[product] => Array
(
[url] => banners
[name] => Banners
)
)