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

Martin Kutschker masi-no at spam-typo3.org
Sun Aug 24 15:28:40 CEST 2008


Steffen Kamper schrieb:
> Francois Suter schrieb:
>> Hi Steffen,
>>
>>> you're right, open is for URI and XML for string.
>>> Important is the setParserProperty, so here is the working example:
>>
>> I've finally got the following code working:
>>
>> $xml = '<test><foo>dummy</bar></test>';
>> $reader = new XMLReader();
>> $reader->XML($xml);
>> $reader->setParserProperty(XMLReader::VALIDATE, true);
>> if ($reader->isValid()) {
>>     echo 'OK';
>> }
>> else {
>>     echo 'KO';
>> }
>>
>> but I'm pretty puzzled, because it returns OK, although the XML is
>> obviously not valid. simplexml_load_string() returns false in such a
>> case...
>>
>> Cheers
>>
> 
> Hi Francois,
> 
> yes, it's like exploring an undocumented feature :-) The docs are really
> spare.
> 
> I tested a while and found some infos about.
> $reader->setParserProperty(XMLReader::VALIDATE, true); Loads a DTD and
> validate against. As there is no DTD it always returns true, even if XML
> isn't valid

To be valid it must be well-formed. But you don't want to validate
against a DTD or a schema, you are only interested if it's well formed.

But it's strange that broken XML data doesn't trigger an error of some kind.

Masi


More information about the TYPO3-team-core mailing list