This is a draft cheat sheet. It is a work in progress and is not finished yet.
XML
Which of the following parts must a XML document have in order to be well-formed?
A. An XML declaration
B. A root element
C. A specified encoding
D. A reference to either a DTD or an XML schema definition |
XML
SimpleXML provides the ability to iterate over items in an XML document, as well as access items within it as if they were object properties. When creating your own classes to access data, implementing which of the following would NOT achieve this goal?
A. __toString
B. Iterator
C. __get/__set
D. ArrayAccess |
Rules
Which of the following rules must every correct XML document adhere to? (Choose 2)
A. It has to be well-formed.
B. It has to be valid.
C. It has to be associated to a DTD.
D. It may only contain UTF-8 encoded characters. |
code
The XML document below has been parsed into $xml via SimpleXML. How can the value of <foo> tag accessed?
<?xml version='1.0'?>
<document>
<bar>
<foo>Value</foo>
</bar>
</document>
A. $xml->bar['foo']
B. $xml->bar->foo
C. $xml['document']['bar']['foo']
D. $xml->document->bar->foo
E. $xml->getElementByName('foo'); |
code
The XML document below has been parsed into $xml via SimpleXML. How can the value of <foo> tag accessed?
<?xml version='1.0'?>
<document>
<bar>
<foo>Value</foo>
</bar>
</document>
A. $xml->bar['foo']
B. $xml->bar->foo
C. $xml['document']['bar']['foo']
D. $xml->document->bar->foo
E. $xml->getElementByName('foo'); |
|
|
code
Consider the following XML code:
<?xml version="1.0" encoding="utf-8"?>
<books>
<book id="1">PHP 5.5 in 42 Hours</book>
<book id="2">Learning PHP 5.5 The Hard Way</book>
</books>
Which of the following SimpleXML calls prints the name of the second book?
(Let $xml = simplexml_load_file("books.xml"); .) (Choose 2)
A. echo $xml->books->book[2];
B. echo $xml->books->book[1];
C. echo $xml->book[1];
D. echo $xml->xpath("/books/book[@id=2]");
E. $c = $xml->children(); echo $c[1]; |
XML
Which one of the following XML declarations is NOT valid?
A. <?xml version="1.0" ?>
B. <?xml version="1.1" encoding="UTF-8" ?>
C. <?xml standalone="no" ?>
D. <?xml standalone="1" ?> |
parsing
What parsing methodology is utilized by the SimpleXML extension?
A. SAX
B. DOM
C. XPath
D. Push/Pull Approach
E. Expat |
|
|
SimpleXML
Which of the following statements are FALSE?
A. SimpleXML allows removal of attributes.
B. SimpleXML allows addition of new attributes.
C. SimpleXML allows removal of nodes.
D. SimpleXML allows addition of new nodes.
E. None of the above |
SimpleXML func
What SimpleXML function is used to parse a file?
A. simplexml_load_file()
B. simplexml_load_string()
C. load()
D. loadFile()
E. loadXML()
F. None of the above. |
SimpleXML
What is the method used to execute Xpath queries in the SimpleXML extension?
A. xpathQuery()
B. xpath()
C. simpleXMLXpath()
D. query()
E. evaluate() |
XML
How can a SimpleXML object be converted to a DOM object?
A. dom_import_simplexml()
B. dom_export_simplexml()
C. simplexml_import_dom()
D. SimpleXML2Dom()
E. None of the above. |
|