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 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); 27print $output; 28?> 29--EXPECT-- 30<?xml version="1.0" encoding="UTF-8"?> 31<root> 32 <ns1:child1 ns1:att1="<>"'&" xmlns:ns1="urn:ns1"> 33 <chars>special characters: <>"'&</chars> 34 </ns1:child1> 35</root> 36