OO_005.phpt 745 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. XMLWriter: libxml2 XML Writer, comments
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("xmlwriter")) die("skip");
  6. if (!function_exists("xmlwriter_start_comment")) die("skip: libxml2 2.6.7+ required");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* $Id$ */
  11. $doc_dest = '001.xml';
  12. $xw = new XMLWriter();
  13. $xw->openUri($doc_dest);
  14. $xw->startDocument('1.0', 'UTF-8');
  15. $xw->startElement("tag1");
  16. $xw->startComment();
  17. $xw->text('comment');
  18. $xw->endComment();
  19. $xw->writeComment("comment #2");
  20. $xw->endDocument();
  21. // Force to write and empty the buffer
  22. $output_bytes = $xw->flush(true);
  23. echo file_get_contents($doc_dest);
  24. unset($xw);
  25. unlink('001.xml');
  26. ?>
  27. ===DONE===
  28. --EXPECT--
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <tag1><!--comment--><!--comment #2--></tag1>
  31. ===DONE===