0

Currently I am working on javascript code in order to request an external API of my network.

The response of the API is in JSON format and my code convert it in XML format. The request and the conversion of data works well.

Unfortunately when I want to use the output xml file for the purpose of insert data in an application I have an error with a "SOH" character. It is the only one character type that I have a problem with.

Within this application I can only use 4 libraries because the code is executed in a sandboxed environment. The allowed libraries are "request", "xpath", "xmldom" and "xml2js" and I am obliged to use xml 1.0 because I had seen that in version 1.1 of xml the SOH character was handled.

Someone know how to escape or replace this character in my xml output?

If you need further informations let me know.

Thanks in advance!

Below an example of my error:

<upper_xmlTag>...
<xmlTag>my_string SOH (the character appears in the middle of the sentence.) end_of_string</xmlTag>
<bottom_xmlTag>...
0xffxd
  • 3
  • 3

1 Answers1

1

As you have noted, the SOH character (0x01) is not legal in XML 1.0, and there is no standard way of representing it in XML.

Before giving advice on how to represent it, I would want to ask more about why it appears and what semantics it conveys.

One way, not necessarily the right way or the best way, it to use a processing instruction such as <?hex 01?>.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164