PrepAway - Latest Free Exam Questions & Answers

Which of the following SimpleXML calls prints the name of the second book?

Consider the following XML code: <?xml version=”1.0″ encoding=”utf-8″?> <books> <book
id=”1″>PHP 5.5 in 42 Hours</book> <book id=”2″>Learning PHP 5.5 The Hard Way</book>
</books> Which of the following SimpleXML calls prints the name of the second book? (Let
$xml = simplexml_load_file(“books.xml”); .) (Choose 2)

PrepAway - Latest Free Exam Questions & Answers

A.
echo $xml->books->book[2];

B.
$c = $xml->children(); echo $c[1];

C.
echo $xml->xpath(“/books/book[@id=2]”);

D.
echo $xml->books->book[1];

E.
echo $xml->book[1];

Explanation:


Leave a Reply

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