Edit report at https://bugs.php.net/bug.php?id=55317&edit=1
ID: 55317 Comment by: virtual dot greg at gmail dot com Reported by: schalk at unf dot edu Summary: SimpleXML loses DTD declaration on simplexml_load_file Status: Open Type: Bug Package: SimpleXML related Operating System: OSX 10.6.8 PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: This does not manifest in 5.3.8 on OS X 10.6.8, the '<!DOCTYPE' is not removed. I'd post my test script and output but I keep getting the error "Please do not SPAM our bug system." Previous Comments: ------------------------------------------------------------------------ [2011-07-29 11:44:00] schalk at unf dot edu Description: ------------ I guess this may not be a bug but I can find no information about how to import an XML with a DTD declaration (<!DOCTYPE...) and have the resulting XML still contain the declaration when I use the asXML method. All I get is the file with the declaration removed. I have tried LIBXML_DTDLOAD, LIBXML_DTDATTR and they don't seem to help. On a related note when I set an element using simplexml and it includes an '&' ans part of an entity reference (i.e. &M;) it gets converted to '&'. How can I stop that? Test script: --------------- $exptml= simplexml_load_file('http://chalk.coas.unf.edu/eureka/files/templates/tmpl_chm.xml'); echo $exptml->asXML(); Expected result: ---------------- <?xml version="1.0" encoding="UTF-8"?> <!-- Example Chemical - ExptML v0.1 SJC 4/7/11 --> <!DOCTYPE ExptML SYSTEM "http://chalk.coas.unf.edu/eureka/files/exptml/exptml_entities.dtd"> <chemical id="pid" xmlns="urn:exptml:schema:draft:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:unitsml="urn:oasis:names:tc:unitsml:schema:xsd:UnitsMLSchema-1.0" xsi:schemaLocation="urn:exptml:schema:draft:0.1 http://chalk.coas.unf.edu/eureka/files/exptml/exptml_chemical.xsd" version="0.1"> <name>Chemical name</name> ... </chemical> Actual result: -------------- <?xml version="1.0" encoding="UTF-8"?> <!-- Example Chemical - ExptML v0.1 SJC 4/7/11 --> <chemical id="pid" xmlns="urn:exptml:schema:draft:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:unitsml="urn:oasis:names:tc:unitsml:schema:xsd:UnitsMLSchema-1.0" xsi:schemaLocation="urn:exptml:schema:draft:0.1 http://chalk.coas.unf.edu/eureka/files/exptml/exptml_chemical.xsd" version="0.1"> <name>Chemical name</name> ... </chemical> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55317&edit=1