Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 928 Bytes

0681.md

File metadata and controls

31 lines (26 loc) · 928 Bytes

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