3 quizzes found.

What does the following PHP script accomplish?

<?php $dom = new DomDocument(); $dom->load('test.xml'); $body = $dom->documentElement->getElementsByTagName('body')->item(0); echo $body->getAttributeNode('background')->value. "\n";?>
  1. Displays the content of every <body> node
  2. Displays the "background" attribute for the first node in the XML document named "body"
  3. Displays the content of every node that has a "background" node
  4. Displays the "background" attribute of every node named "body"

Choose 1 answers

Creating new nodes in XML documents using PHP can be done using which XML/PHP 5 technologies?

  1. XQuery
  2. XPath
  3. SimpleXML
  4. DOM
  5. SAX

Choose 2 answers

Consider the following script; Assuming the referenced XML document exists and matches the parsing logic, what should be displayed when this script is executed?

<?php$dom = new DOMDOcument();$dom->load("myxmlfile.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"; } } }}?>
  1. None of the above
  2. The XML of each 'title' node
  3. The XML of each 'item' node
  4. "Title" for every title node in the document
  5. The contents of every 'title' node which exists under an 'item' node

Choose 1 answers