OO_010.phpt 990 B

123456789101112131415161718192021222324252627282930313233343536
  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. --SKIPIF--
  7. <?php
  8. if (!extension_loaded("xmlwriter")) die("skip");
  9. if (LIBXML_VERSION < 20617) die("skip: libxml2 2.6.17+ required");
  10. ?>
  11. --FILE--
  12. <?php
  13. /* $Id$ */
  14. $xw = new XMLWriter();
  15. $xw->openMemory();
  16. $xw->setIndent(TRUE);
  17. $xw->setIndentString(' ');
  18. $xw->startDocument('1.0', "UTF-8");
  19. $xw->startElement('root');
  20. $xw->startElementNS('ns1', 'child1', 'urn:ns1');
  21. $xw->writeAttributeNS('ns1', 'att1', 'urn:ns1', '<>"\'&');
  22. $xw->writeElement('chars', "special characters: <>\"'&");
  23. $xw->endElement();
  24. $xw->endDocument();
  25. // Force to write and empty the buffer
  26. $output = $xw->flush(true);
  27. print $output;
  28. ?>
  29. --EXPECT--
  30. <?xml version="1.0" encoding="UTF-8"?>
  31. <root>
  32. <ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
  33. <chars>special characters: &lt;&gt;&quot;'&amp;</chars>
  34. </ns1:child1>
  35. </root>