DOMDocument_documentURI_basic.phpt 880 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Tests DOMDocument::documentURI read and write
  3. --CREDITS--
  4. Chris Snyder <chsnyder@gmail.com>
  5. # TestFest 2009 NYPHP
  6. --EXTENSIONS--
  7. dom
  8. --FILE--
  9. <?php
  10. // create dom document
  11. $dom = new DOMDocument;
  12. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  13. <!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
  14. <s1>foo</s1>';
  15. $dom->loadXML($xml);
  16. if(!$dom) {
  17. echo "Error while parsing the document\n";
  18. exit;
  19. }
  20. echo "DOMDocument created\n";
  21. $test = $dom->documentURI;
  22. echo "Read initial documentURI:\n";
  23. echo $test."\n";
  24. $dom->documentURI = 'http://dom.example.org/example.xml';
  25. $test = $dom->documentURI;
  26. echo "Set documentURI to a URL, reading again:\n";
  27. var_dump( $test );
  28. echo "Done\n";
  29. ?>
  30. --EXPECTF--
  31. DOMDocument created
  32. Read initial documentURI:
  33. %s
  34. Set documentURI to a URL, reading again:
  35. string(34) "http://dom.example.org/example.xml"
  36. Done