003.phpt 799 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. XMLWriter: libxml2 XML Writer, membuffer, flush, attribute
  3. --EXTENSIONS--
  4. xmlwriter
  5. --FILE--
  6. <?php
  7. $xw = xmlwriter_open_memory();
  8. xmlwriter_start_document($xw, '1.0', 'UTF-8');
  9. xmlwriter_start_element($xw, "tag1");
  10. $res = xmlwriter_start_attribute($xw, 'attr1');
  11. xmlwriter_text($xw, "attr1_value");
  12. xmlwriter_end_attribute($xw);
  13. xmlwriter_write_attribute($xw, "att2", "att2_value");
  14. xmlwriter_text($xw, "Test text for tag1");
  15. $res = xmlwriter_start_element($xw, 'tag2');
  16. if ($res < 1) {
  17. echo "StartElement context validation failed\n";
  18. exit();
  19. }
  20. xmlwriter_end_document($xw);
  21. // Force to write and empty the buffer
  22. echo xmlwriter_flush($xw, true);
  23. ?>
  24. --EXPECT--
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <tag1 attr1="attr1_value" att2="att2_value">Test text for tag1<tag2/></tag1>