create_element_ns("http://www.w3.org/1999/xhtml","html", "xh"); $head = $doc->create_element_ns("http://www.w3.org/1999/xhtml","head", "xh"); $title = $doc->create_element_ns("http://www.w3.org/1999/xhtml","title", "xh"); $body = $doc->create_element_ns("http://www.w3.org/1999/xhtml","body", "xh"); $p = $doc->create_element_ns("http://www.w3.org/1999/xhtml","p", "xh"); $text = $doc->create_text_node("Testing"); $doc->append_child($html); $html->append_child($head); $html->append_child($body); $head->append_child($title); $text = $doc->create_text_node("Testing"); $title->append_child($text); $text = $doc->create_text_node("Testing"); $p->append_child($text); $body->append_child($p); */ if (!$dom = domxml_open_file("test.xhtml")) { echo "Error while parsing the document\n"; exit; } $root = $dom->document_element(); $p = $dom->create_element("p"); $text = $dom->create_text_node("Added paragraph."); $p->append_child($text); $body = $root->get_elements_by_tagname("body");// $body[0]->append_child($p); echo $dom->dump_mem(true, 'UTF-8'); ?>