I have a web app (in PHP) which selects the data of an XML element depending on the attribute's value.
However, I'm having trouble trying to actually do this. Here is the XML which I'm using:
<meta> <!-- Data about data -->
<genre genre_name="edm">
<amount_of_bands>3</amount_of_bands>
/genre>
<genre genre_name="pop">
<amount_of_bands>3</amount_of_bands>
</genre>
<genre genre_name="hip-hop">
<amount_of_bands>1</amount_of_bands>
</genre>
</meta>
I'm trying to access the numbers in the tags.
I've tried using $xml_root->meta->genre['genre_name = edm']->amount_of_bands;
(with SimpleXML)), and that yields nothing. I've tried researching, but I still get nothing.
EDIT, YO - I fixed my problem by replacing <genre genre_name="hip-hop">
with an extra <genre_name>hip-hop</genre_name>
element inside the <genre>...</genre>
element. Much easier to read, maintain and code with.
Thanks for the answers, regardless.