xref: /PHP-7.4/ext/xmlwriter/tests/OO_010.phpt (revision 782352c5)
1--TEST--
2XMLWriter: libxml2 XML Writer, writeAttributeNS method
3--CREDITS--
4Mauricio Vieira <mauricio [at] @mauriciovieira [dot] net>
5#testfest PHPSP on 2014-07-05
6--SKIPIF--
7<?php
8if (!extension_loaded("xmlwriter")) die("skip");
9?>
10--FILE--
11<?php
12
13$xw = new XMLWriter();
14$xw->openMemory();
15$xw->setIndent(TRUE);
16$xw->setIndentString('   ');
17$xw->startDocument('1.0', "UTF-8");
18$xw->startElement('root');
19$xw->startElementNS('ns1', 'child1', 'urn:ns1');
20$xw->writeAttributeNS('ns1', 'att1', 'urn:ns1', '<>"\'&');
21$xw->writeElement('chars', "special characters: <>\"'&");
22$xw->endElement();
23$xw->endDocument();
24// Force to write and empty the buffer
25$output = $xw->flush(true);
26print $output;
27?>
28--EXPECT--
29<?xml version="1.0" encoding="UTF-8"?>
30<root>
31   <ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
32      <chars>special characters: &lt;&gt;&quot;'&amp;</chars>
33   </ns1:child1>
34</root>
35