Whatever you see in “[some_node]” is what you use to “drill down” to what you’re after. eg.
$xml->icon_set[2]->icon_url
depends on you knowing the numeric “key”, ie. “2” in this case.
print_r is definately helpful … thanks for that tip.
i knew i could use node numbers, such as specifying
$var1 = $xml->icons->icon_set[3]->icon_url
but was just curious if it was possible, and if so how, to get the url assigned to $var1 based on the “name=” within icon_set
just in case the list order was ever changed, my script would continue to pull the correct url based on the set name and not whatever happens to be sitting in the icon_set[3] node.
i dont suspect the list would ever change order, was just thinking ahead
haven’t looked into xpath yet … but will give it a read.
I guess you could get the attribute values and use test conditionals.
If you start to get messy/long files, you could include “it”; as a file or a Class.
But if you know straight off where what you want is, then using XPATH gives good results digging down to what’s wanted.
More complex a language in ways, but once you grasp the basics the rest comes quick (well, it did for me, relatively speaking) it makes for cleaner code.