nerdexam
Zend

200-710 · Question #174

The XML document below has been parsed into $xml via SimpleXML. How can the value of <foo> tag accessed? ``xml <?xml version='1.0'?> <document> <bar> <foo>Value</foo> </bar> </document> ``

The correct answer is B. $xml->bar->foo. See the full explanation below for the reasoning.

XML & Web Services

Question

The XML document below has been parsed into $xml via SimpleXML. How can the value of <foo> tag accessed?
<?xml version='1.0'?>
<document>
 <bar>
 <foo>Value</foo>
 </bar>
</document>

Options

  • A$xml->bar['foo']
  • B$xml->bar->foo
  • C$xml['document']['bar']['foo']
  • D$xml->document->bar->foo
  • E$xml->getElementByName('foo');

How the community answered

(57 responses)
  • A
    11% (6)
  • B
    82% (47)
  • C
    2% (1)
  • D
    2% (1)
  • E
    4% (2)

Topics

#SimpleXML#object property access#XML navigation

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice