HTML entity in JavaScript (XML and PHP) -
newbie in troubles again))) need yr guys!
i have xml file data this:
<page> <content><p>article content</p> <h1 style="font-style: italic;">header</h1> <p>&nbsp;</p> <p><img alt="" src="/upload/images/1.jpg" style="height:51px; width:144px" /></p> </content> </page>
now want extract data via php & replace html jq.
<?php $file = '111.xml'; $xml = simplexml_load_file($file); $str =$xml->content; $str = htmlspecialchars($str, ent_quotes); js('var conv = "'.$str.'"'); //js function puts parametr between <script... tags echo $str; ?> <script type="text/javascript"> $("#debug").html().text(conv); </script>
so result nothing... if echo - works, if replace conv value smth "bla bla bla" - works either. encoded or decoded html shows none...
update: still dont know where's problem. use "buffer" file temporary soultion:
file_put_contents('../plugins/'.pl_dir().'/buffer.db', $str, lock_ex); js('$("#editor").load("../../plugins/"+path+"/buffer.db")');
via ajax content loads anyway im sure that's diffenetley not best idea...
you should try replace
$str = htmlspecialchars($str, ent_quotes);
with
$str = htmlspecialchars_decode($str, ent_quotes);
see http://php.net/manual/en/function.htmlspecialchars-decode.php
i had similar problem other day, , solved me.
Comments
Post a Comment