OO_010.phpt 863 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. XMLWriter: libxml2 XML Writer, writeAttributeNS method
  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 = new XMLWriter();
  11. $xw->openMemory();
  12. $xw->setIndent(TRUE);
  13. $xw->setIndentString(' ');
  14. $xw->startDocument('1.0', "UTF-8");
  15. $xw->startElement('root');
  16. $xw->startElementNS('ns1', 'child1', 'urn:ns1');
  17. $xw->writeAttributeNS('ns1', 'att1', 'urn:ns1', '<>"\'&');
  18. $xw->writeElement('chars', "special characters: <>\"'&");
  19. $xw->endElement();
  20. $xw->endDocument();
  21. // Force to write and empty the buffer
  22. $output = $xw->flush(true);
  23. print $output;
  24. ?>
  25. --EXPECT--
  26. <?xml version="1.0" encoding="UTF-8"?>
  27. <root>
  28. <ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
  29. <chars>special characters: &lt;&gt;&quot;'&amp;</chars>
  30. </ns1:child1>
  31. </root>