I have the following array set in an XML file:
<?xml version="1.0"?>
<hats>
<a id="Chicago BULLS" img="bulls.jpeg" cost="$25.00" />
<b id="Toronto RAPTORS" img="raptors.jpeg" cost="$25.00" />
<c id="Orlando MAGIC" img="magic.jpeg" cost="$25.00" />
</hats>
<clothes>
<a id="Chicago BULLS 23" img="bullstee.jpeg" cost="$30.00" />
<b id="Toronto RAPTORS 23" img="torontotee.jpeg" cost="$30.00" />
<c id="Orlando MAGIC 23" img="magictee.jpeg" cost="$30.00" />
</clothes>
I have used a function I found to convert the XML into a Multidimensional Array which looks like this:
Array
(
[hats] => Array
(
[a] => Array
(
)
[a_attr] => Array
(
[id] => Chicago BULLS
[img] => bulls.jpeg
[cost] => $25.00
)
[b] => Array
(
)
[b_attr] => Array
(
[id] => Toronto RAPTORS
[img] => raptors.jpeg
[cost] => $25.00
)
[c] => Array
(
)
[c_attr] => Array
(
[id] => Orlando MAGIC
[img] => magic.jpeg
[cost] => $25.00
)
)
)
As you can see it has only taken half of the XML file, and also I am unable to use numbers so have to resort to letters.
Ultimately I am trying to have it read the XML file then output only what is shown within the tags and tags and eventually more.
How can I parse the XML file cleanly into an array so I can then use a foreach loop to show each line in a given section of the XML file (hats only or clothes only).