4 quizzes found.

When working with SimpleXML in PHP 5, the four basic rules on how the XML document is accessed are which of the following?

  1. Element namespaces are denoted by the 'namespace' attribute
  2. converting an element to a string denotes text data
  3. Non-numeric indexes are element attributes
  4. Numeric indexes are elements
  5. Properties denote element iterators

Choose 4 answers

SimpleXML objects can be created from what types of data sources?

  1. A String
  2. An array
  3. A DomDocument object
  4. A URI
  5. A Database resource

Choose 3 answers

Given the following PHP script; What should go in place of ????? above to print the string Hello, World! (with no leading/trailing whitespace or markup)?


$xmldata = <<< XML
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <title>XML Example</title>
      <b>Hello, World!</b>

$sxe = simplexml_load_string($xmldata);

$p = $sxe->body->p;

$string = ????????

print $string;
  1. trim(($p[1]));
  2. trim(strip_tags(($p->asText())));
  3. trim(strip_tags(($p->asXML())));
  4. trim(($p->asXML()));
  5. strip_tags(($p->asXML()));

Choose 1 answers

Which of the following functions in SimpleXML can be used to return an iterator containing a list of all subnodes of the current node?

  1. asXML()
  2. attributes()
  3. getName()
  4. children()

Choose 1 answers