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