Hello, I have this piece of XML:
<foo id="whatever" default="whatever">
FOO
</foo>
How can I access attributes like id or default?
If I print_r($xml->foo) I see them, but they are prepended with @
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the array syntax for attributes and object syntax for child nodes:
See the
Using attributesexample here: http://docs.php.net/manual/en/simplexml.examples-basic.php#example-4741See also the
attributes()method.