<?xml version="1.0" encoding="utf-8"?
Consider the following XML code:
<?xml version="1.0" encoding="utf-8"?>
<books>
<book id="l">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)
A . echo $xml->books->book[2];
B . echo $xml->books->book[l];
C . echo $xml->book[l];
D . echo $xml->xpath("/books/book[@id=2]");
E . $c = $xml->children(); echo $c[l];
Answer: C, E
Subscribe
Login
0 Comments
Inline Feedbacks
View all comments