[TYPO3-core] RFC: Bug #9217: typo3ajax::renderAsXML does not always render XML

Steffen Kamper info at sk-typo3.de
Sat Aug 23 18:31:33 CEST 2008


Francois Suter schrieb:
> Hi Steffen,
> 
>> Example:
>> $xml = XMLReader::open($this->content);
>> $xml->setParserProperty(XMLReader::VALIDATE, true);
>> if ($xml->isValid()) {...}
> 
> The above code is wrong. I searched a bit and came up with the following 
> test code:
> 
> $xml = '<test><value>dummy</value></test>';
> $reader = new XMLReader();
> $reader->XML($xml);
> if ($reader->isValid()) {
>     echo 'OK';
> }
> else {
>     echo 'KO';
> }
> 
> but it sternly refuses to validate my XML. Adding the XML prologue:
> 
> $xml = '<?xml version="1.0" 
> encoding="UTF-8"?><test><value>dummy</value></test>';
> 
> doesn't help either, so I'm not sure your solution is such a good idea. 
> Do you actually have a working example?
> 
> Cheers
> 

Hi Francois,

you're right, open is for URI and XML for string.
Important is the setParserProperty, so here is the working example:

$content = '<test><value>dummy</value></test>';
$xml = XMLReader::XML($content);
$xml->setParserProperty(XMLReader::VALIDATE, true);
if ($xml->isValid()) {
	echo 'valid';
} else {
	echo 'not valid';
}

vg Steffen


More information about the TYPO3-team-core mailing list