pastebin

Paste Search Dynamic
Recent pastes
xml
  1. <?php
  2. header("Content-Type: application/xml");
  3. /*
  4. $doc = domxml_new_doc("1.0");
  5. $html = $doc->create_element_ns("http://www.w3.org/1999/xhtml","html", "xh");
  6. $head = $doc->create_element_ns("http://www.w3.org/1999/xhtml","head", "xh");
  7. $title = $doc->create_element_ns("http://www.w3.org/1999/xhtml","title", "xh");
  8. $body = $doc->create_element_ns("http://www.w3.org/1999/xhtml","body", "xh");
  9. $p = $doc->create_element_ns("http://www.w3.org/1999/xhtml","p", "xh");
  10. $text = $doc->create_text_node("Testing");
  11.  
  12. $doc->append_child($html);
  13. $html->append_child($head);
  14. $html->append_child($body);
  15. $head->append_child($title);
  16. $text = $doc->create_text_node("Testing");
  17. $title->append_child($text);
  18. $text = $doc->create_text_node("Testing");
  19. $p->append_child($text);
  20. $body->append_child($p);
  21. */
  22.  
  23.  
  24. if (!$dom = domxml_open_file("test.xhtml")) {
  25.   echo "Error while parsing the documentn";
  26.   exit;
  27. }
  28.  
  29. $root = $dom->document_element();
  30. $p = $dom->create_element("p");
  31. $text = $dom->create_text_node("Added paragraph.");
  32. $p->append_child($text);
  33. $body = $root->get_elements_by_tagname("body");//
  34. $body[0]->append_child($p);
  35.  
  36. echo $dom->dump_mem(true, 'UTF-8');
  37. ?>
Parsed in 0.016 seconds