Why does "xmlwrite" escape "é" as "&#xE9"?

14 views (last 30 days)
When writing an XML file containing numerical representation of special characters, the ampersand (&) is modified to "&".
For instance, the French accented character "é" can be represented by the numerical representation "&#xE9". However, "xmlwrite" modifies the ampersand to "&".<https://www.w3.org/TR/xml/#syntax>

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Apr 2019
Edited: MathWorks Support Team on 15 Apr 2019
Please note that, as far as having "&" characters in an XML file, this is technically not supported according to the XML Specification, and a standards-compliant XML encoder should always escape "&" characters. Please refer to the following snippet from the XML Specification (<https://www.w3.org/TR/xml/#syntax>):
"The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings " & " and " < " respectively."
If you want to code the representation of some special characters, you can use the Unicode representation for it and use the "native2unicode" function.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!