echo "--------- attributes of rootnode\n";
$attrs = $rootnode->attributes;
print_node_list($attrs);
-
+var_dump($attrs);
echo "--------- children of an attribute\n";
+var_dump($children = $attrs->item(0));
$children = $attrs->item(0)->childNodes;
print_node_list($children);
?>
--EXPECTF--
--- Catch exception with try/catch
-object(domexception)#%d (6) {
+object(DOMException)#%d (6) {
["code"]=>
int(3)
}
--- Don't catch exception with try/catch
-Fatal error: Uncaught exception 'domexception' with message 'Hierarchy Request Error' in %sdom003.php:%d
+Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
Stack trace:
#0 {main}
thrown in %sdom003.php on line %d
<?php
Class books extends domDocument {
- function __construct() {
- /* We must first call the constructor for the parent to create the document
- otherwise this class will not work */
- parent::__construct();
- }
-
function addBook($title, $author) {
$titleElement = $this->createElement("title");
$titleElement->appendChild($this->createTextNode($title));