XML : special characters on JSON to xml

I'm working with Javascript and PHP.

I jave a JSON like this:

  [{"id": 32, "label": "Some Title", "type": "tinymce", "value": "<!DOCTYPE html>↵<html>↵<head>↵</head>↵<body>↵<p>asdasdasda&nbsp;30-09-2017</p>↵</body>↵</html>"}]    

The real JSON is a loong array of objects/arrays. I'm creating an XML file (with .xls extension) that will be read is Excel. With normal characters everything works correct, but I can't put those special characters in order to get Excel reading that XML file. What can I do?

What can not do is:

  • Using another format: I need to read the XML with and .xls extension.
  • Change the data from the JSON, it's external.

In the way I'm doing i, tThe XML results in something like this:

  <ss:Row>    <ss:Cell>      <ss:Data ss:Type="String"></ss:Data>    </ss:Cell>    <ss:Cell>      <ss:Data ss:Type="String"></ss:Data>    </ss:Cell>    <ss:Cell>      <ss:Data ss:Type="String"></ss:Data>    </ss:Cell>    <ss:Cell>      <ss:Data ss:Type="String">Objeto del contrato</ss:Data>    </ss:Cell>    <ss:Cell>      <ss:Data ss:Type="String"><!DOCTYPE html> // I don't need all the html tags, I just need to put the text of the <p> tags.  <html>  <head>  </head>  <body>  <p>asdasdasda&nbsp;30-09-2017</p>  </body>  </html></ss:Data>//here ends the wrong text coming from the JSON    </ss:Cell>  </ss:Row>    

which is not correct for Excel.

No comments:

Post a Comment