HTML entity in JavaScript (XML and PHP) -


newbie in troubles again))) need yr guys!

i have xml file data this:

<page> <content>&lt;p&gt;article content&lt;/p&gt;&#13; &#13; &lt;h1 style="font-style: italic;"&gt;header&lt;/h1&gt;&#13; &#13; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&#13; &#13; &lt;p&gt;&lt;img alt="" src="/upload/images/1.jpg" style="height:51px; width:144px" /&gt;&lt;/p&gt;&#13; </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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -