]> Title &sp; a1b1c1 a2c2 a3b3c3 "; echo "Test 1: accessing single nodes from php\n"; $dom = xmldoc($xmlstr); if(!$dom) { echo "Error while parsing the document\n"; exit; } $children = $dom->childNodes(); print_r($children); echo "--------- root\n"; $rootnode = $dom->documentElement(); print_r($rootnode); echo "--------- children of root\n"; $children = $rootnode->childNodes(); print_r($children); // The last node should be identical with the last entry in the children array echo "--------- last\n"; $last = $rootnode->lastChild(); print_r($last); // The parent of this last node is the root again echo "--------- parent\n"; $parent = $last->parent(); print_r($parent); // The children of this parent are the same children as one above echo "--------- children of parent\n"; $children = $parent->childNodes(); print_r($children); echo "--------- creating a new attribute\n"; $attr = $dom->createAttribute("src", "picture.gif"); print_r($attr); $rootnode->setAttributeNode($attr); /* Not implemented */ $attr = $rootnode->setAttribute("src", "picture.gif"); $attr = $rootnode->getAttribute("src"); print_r($attr); echo "--------- attribute of rootnode\n"; $attrs = $rootnode->attributes(); print_r($attrs); echo "--------- children of an attribute\n"; $children = $attrs[0]->childNodes(); print_r($children); ?>