|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-06-25 13:08 UTC] a dot anpilogov at gmail dot com
Description:
------------
It is possible to create invalid XML file using XMLwriter. In my case, the first symbol of Unicode text was 00 13, and XMLWriter just put it out, so I had to call preg_replace('/^.{1}/us', '', $str) to make valid UTF-8 string, than pass it to XMLWriter.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
<?php $xw = new XMLWriter(); $xw->openMemory(); $xw->startDocument('1.0', 'UTF-8'); $xw->writeElement('root', "\x04\xA0"); $xw->endDocument(); header('Content-type: application/xml'); print $xw->outputMemory(true); ?> Output will be an invalid XML. Another example: <?php $xw = new XMLWriter(); $xw->openMemory(); $xw->startDocument('1.0', 'ISO-8559-1'); $xw->writeElement('root', "\x04\xA0"); $xw->endDocument(); header('Content-type: application/xml'); print $xw->outputMemory(true); ?> Warning: XMLWriter::startDocument() [function.XMLWriter-startDocument]: xmlTextWriterStartDocument : out of memory!