Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- XMLWriter: libxml2 XML Writer, membuffer, flush, text, attribute --EXTENSIONS-- x..
Decoded Output download
--TEST--
XMLWriter: libxml2 XML Writer, membuffer, flush, text, attribute
--EXTENSIONS--
xmlwriter
--FILE--
<?php
$xw = new XMLWriter();
$xw->openMemory();
$xw->startDocument('1.0', 'UTF-8');
$xw->startElement("tag1");
$res = $xw->startAttribute('attr1');
$xw->text("attr1_value");
$xw->endAttribute();
$res = $xw->startAttribute('attr2');
$xw->text("attr2_value");
$xw->endAttribute();
$xw->text("Test text for tag1");
$res = $xw->startElement('tag2');
if ($res < 1) {
echo "StartElement context validation failed
";
exit();
}
$xw->endDocument();
// Force to write and empty the buffer
echo $xw->flush(true);
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<tag1 attr1="attr1_value" attr2="attr2_value">Test text for tag1<tag2/></tag1>
Did this file decode correctly?
Original Code
--TEST--
XMLWriter: libxml2 XML Writer, membuffer, flush, text, attribute
--EXTENSIONS--
xmlwriter
--FILE--
<?php
$xw = new XMLWriter();
$xw->openMemory();
$xw->startDocument('1.0', 'UTF-8');
$xw->startElement("tag1");
$res = $xw->startAttribute('attr1');
$xw->text("attr1_value");
$xw->endAttribute();
$res = $xw->startAttribute('attr2');
$xw->text("attr2_value");
$xw->endAttribute();
$xw->text("Test text for tag1");
$res = $xw->startElement('tag2');
if ($res < 1) {
echo "StartElement context validation failed\n";
exit();
}
$xw->endDocument();
// Force to write and empty the buffer
echo $xw->flush(true);
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<tag1 attr1="attr1_value" attr2="attr2_value">Test text for tag1<tag2/></tag1>
Function Calls
None |
Stats
MD5 | 23c2653436c121e65afb04201be16efd |
Eval Count | 0 |
Decode Time | 71 ms |