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

조회 수: 13 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2019년 4월 15일
편집: MathWorks Support Team 2019년 4월 15일
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>

채택된 답변

MathWorks Support Team
MathWorks Support Team 2019년 4월 16일
편집: MathWorks Support Team 2019년 4월 15일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structured Data and XML Documents에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by