1

I get data from My DB, when I show it on browser windows it was correctly encoded, but when i saved into xml file I get data with encoding changed. for exemple : on browser I get this text `

Un texte est une série orale ou écrite de mots perçus comme constituant un ensemble cohérent, porteur de sens et utilisant les structures propres à une langue à là-bas oç ôlala îlolo (conjugaisons, construction et association des phrases…)

on xml file I get : <p>Un texte est une série orale ou écrite de <em>mots</em> perçus comme constituant un ensemble cohérent, porteur de sens et utilisant les structures propres à une langue à là-bas oç <strong>ôlala</strong> îlolo (conjugaisons, construction et association des phrases…)</p>

I don't know what's the problem !!

3
  • your browser is rendering the file, open in notepad to see the real content and look if this is what you want.. note that in xml char < or > is not allowed and there for stored as &lt; or &gt; Commented Oct 28, 2016 at 11:38
  • so is there any problem at all Commented Oct 28, 2016 at 11:39
  • when i open the xml file on using notepad++ I see the file encoding UTF-8 whitout ROM but I get always like this character &lt;p&gt; Commented Oct 28, 2016 at 11:46

2 Answers 2

1

I solved My problem with encoding this text and deleting the html tag :

$description = strip_tags($value['Description']);
$description = preg_replace("/&#?[a-z0-9]+;/i","",$description);
$xml->startElement("description");
$xml->writeRaw(htmlspecialchars_decode($description));
$xml->endElement();

now I have a xml file completely correct.

Sign up to request clarification or add additional context in comments.

Comments

0

It's an htmlentities convertion , place your html content into cdata tag if you want to keep htmlentities <![CDATA[ <p>myhtmlcontent</p>]]>

1 Comment

that's not working, because my text has many html tag so when I use CDATA it became on comment <!--[CDATA[<p-->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.