PrepAway - Latest Free Exam Questions & Answers

How can the id attribute of the 2nd baz element from the XML string below be retrieved from the SimpleXML obje

How can the id attribute of the 2nd baz element from the XML string below be retrieved from the
SimpleXML object found inside $xml?
<code>
<?xmlversion=’1.0′?>
<foo>
<bar>
<baz id=”1″>One</baz>
<baz id=”2″>Two</baz>
</bar>
</foo>
</code>

PrepAway - Latest Free Exam Questions & Answers

A.
$xml->getElementById(‘2’);

B.
$xml->foo->bar->baz[2][‘id’]

C.
$xml->foo->baz[2][‘id’]

D.
$xml->foo->bar->baz[1][‘id’]

E.
$xml->bar->baz[1][‘id’]

One Comment on “How can the id attribute of the 2nd baz element from the XML string below be retrieved from the SimpleXML obje


Leave a Reply

Your email address will not be published. Required fields are marked *