Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 950 Bytes

0533.md

File metadata and controls

31 lines (26 loc) · 950 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) The contents of every 'title' node which exists under an 'item' node
  • B) None of the above
  • C) The XML of each 'title' node
  • D) The XML of each 'item' node
Answer

Answer: A