011.phpt 963 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. XMLWriter: libxml2 XML Writer, write_attribute_ns function
  3. --CREDITS--
  4. Mauricio Vieira <mauricio [at] @mauriciovieira [dot] net>
  5. #testfest PHPSP on 2014-07-05
  6. --EXTENSIONS--
  7. xmlwriter
  8. --FILE--
  9. <?php
  10. $xw = xmlwriter_open_memory();
  11. xmlwriter_set_indent($xw, TRUE);
  12. xmlwriter_set_indent_string($xw, ' ');
  13. xmlwriter_start_document($xw, '1.0', "UTF-8");
  14. xmlwriter_start_element($xw, 'root');
  15. xmlwriter_start_element_ns($xw, 'ns1', 'child1', 'urn:ns1');
  16. xmlwriter_write_attribute_ns($xw, 'ns1','att1', 'urn:ns1', '<>"\'&');
  17. xmlwriter_write_element($xw, 'chars', "special characters: <>\"'&");
  18. xmlwriter_end_element($xw);
  19. xmlwriter_end_document($xw);
  20. // Force to write and empty the buffer
  21. $output = xmlwriter_flush($xw, true);
  22. print $output;
  23. ?>
  24. --EXPECT--
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <root>
  27. <ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
  28. <chars>special characters: &lt;&gt;&quot;'&amp;</chars>
  29. </ns1:child1>
  30. </root>