PrepAway - Latest Free Exam Questions & Answers

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

Consider the following XML code:
<code>
<?xmlversion=”1.0″ encoding=”utf-8″?>
<books>
<book id=”1″>PHP 5 Power Programming</book>
<book id=”2″>Learning PHP 5</book>
</books>
</code>
Which of the following SimpleXML calls print the name of the second book? (Choose 2)
(Let $xml=simplexml_load_file(“books.xml”);)

PrepAway - Latest Free Exam Questions & Answers

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

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

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

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

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

One Comment on “Which of the following SimpleXML calls print the name of the second book?


Leave a Reply

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