<<< Previous question <<< Question ID#0681.md >>> Next question >>>
Consider the following script:
$dom = new DOMDOcument();
$dom->load('0138.xml');
foreach ($dom->documentElement->childNodes as $child) {
if (($child->nodeType == XML_ELEMENT_NODE) && $child->nodeName == "item") {
foreach ($child->childNodes as $item) {
if (($item->nodeType == XML_ELEMENT_NODE) && ($item->nodeName == "title")) {
print "$item->firstChild->data\n";
}
}
}
}
Assuming the referenced XML document exists and matches the parsing logic, what should be displayed when this script is executed?
- A) None of the above
- B) The XML of each 'title' node
- C) The XML of each 'item' node
- D) "Title" for every title node in the document
Answer
Answer: A