php - why libxml2 quotes starting double slash in CDATA with javascript -


this code:

<?php $data = <<<eol <?xml version="1.0"?> <!doctype html public     "-//w3c//dtd xhtml 1.0 strict//en"      "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html>     <script type="text/javascript">     //<![cdata[     var = 123; // js code     //]]>     </script> </html> eol;  $dom = new domdocument(); $dom->preservewhitespace = false; $dom->formatoutput = false; $dom->loadxml($data); echo '<pre>' . htmlspecialchars($dom->savexml()) . '</pre>'; 

this result:

<?xml version="1.0"?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript"><![cdata[ //]]><![cdata[ var = 123; // js code //]]><![cdata[ ]]></script></html> 

if , when remove doctype notation xml document, cdata works , leading/trailing double slash not turned cdata.

what problem here? bug in libxml2? php version 5.2.13 on linux. thanks.

i'm running libxml 2.7.3 php 5.2.11 on os x.

not apples apples comparison maybe you.

when run code (and add closing php tag here output.)

<?xml version="1.0"?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><script type="text/javascript">     //<![cdata[     var = 123; // js code     //]]>     </script></html> 

it appears render correctly want to. maybe version numbers sort out... i'm running older version of php5 (mamp incidentally didn't compile myself.)

hope helps point in direction find answer.

take care!


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -