This is a follow-on question to this:
Getting XML attributes in PHP
I’m struggling to get element values with a namespace prefix. See this example from here: http://itunes.apple.com/us/rss/toppaidapplications/limit=10/genre=6014/xml
<im:image height="53">http://a2.mzstatic.com/us/r1000/114/Purple/v4/bc/0e/86/bc0e8619-5d48-1efe-2ac3-662696fb9a34/mzl.bimldzcn.53x53-50.png</im:image>
<im:image height="75">http://a3.mzstatic.com/us/r1000/114/Purple/v4/bc/0e/86/bc0e8619-5d48-1efe-2ac3-662696fb9a34/mzl.bimldzcn.75x75-65.png</im:image>
If I try and reference the element using $e->im:image I get the following error:
PHP Parse error: syntax error, unexpected ':'
$e->’im:image’ gives me:
PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '{' or '$'
Any suggestions?
UPDATE: I’ve edited the question title which was misleading. It’s actually element values with a namespace prefix (not attributes) that I’m interested in.
When using SimpleXML (as suggested by your previous question) you have to use the children() method to fetch all child elements of a certain namespace, same with attributes().
e.g.
prints