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

14 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 15 Avr 2019
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>

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 16 Avr 2019
Modifié(e) : MathWorks Support Team le 15 Avr 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.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by