Ejemplo n.º 1
0
echo "--------- Remove Attribute Node\n";
$attr = $rootnode->removeAttribute("src");
print "Removed " . $attr . " attributes.\n";
echo "--------- attributes of rootnode\n";
$attrs = $rootnode->attributes;
print_node_list($attrs);
echo "--------- children of an attribute\n";
$children = $attrs->item(0)->childNodes;
print_node_list($children);
echo "--------- Add child to root\n";
$myelement = new domElement("Silly", "Symphony");
$newchild = $rootnode->appendChild($myelement);
print_node($newchild);
print $dom->saveXML();
print "\n";
echo "--------- Find element by tagname\n";
echo "    Using dom\n";
$children = $dom->getElementsByTagname("Silly");
print_node_list($children);
echo "    Using elem\n";
$children = $rootnode->getElementsByTagName("Silly");
print_node_list($children);
echo "--------- Unlink Node\n";
print_node($children->item(0));
$rootnode->removeChild($children->item(0));
print_node_list($rootnode->childNodes);
print $dom->savexml();
echo "--------- Find element by id\n";
print "Not implemented\n";
echo "--------- Check various node_name return values\n";
print "Not needed\n";