nerdexam
Zend

200-710 · Question #176

How can the id attribute of the 2nd baz element from the XML string below be retrieved from the SimpleXML object found inside $xml? ``xml <?xml version='1.0'?> <foo> <bar> <baz id='1'>One</baz> <baz…

Sign in or unlock 200-710 to reveal the answer and full explanation for question #176. The question stem and answer options stay visible for context.

XML & Web Services

Question

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

Options

  • A$xml->getElementById('2');
  • B$xml->foo->bar->baz[2]['id']
  • C$xml->foo->bar[1]['id']
  • D$xml->bar->baz[1]['id']
  • E$xml->bar->baz[1]->attributes()->id

Unlock 200-710 to see the answer

You've previewed enough free 200-710 questions. Unlock 200-710 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#SimpleXML#attributes()#array indexing#XML attributes
Full 200-710 Practice