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