<?xml version=1.0′?

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="l">One</baz>

<baz id="2">Two</baz>

</bar>

</foo>
A . $xml->getElementByld(‘2’);
B . $xml->foo->bar->baz[2][‘id’]
C . $xml->foo->baz[2] [‘id’]
D . $xml->foo->bar->baz[l][‘id’]
E . $xml->bar->baz[l][‘id’]

Answer: E

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>