xml中是否允许使用#字符或&字符?

时间:2022-02-26 22:30:26

i have values with special chars that encoded to ascii in my xml. for example :

我在xml中有编码为ascii的特殊字符的值。例如:

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <name>&#381;irm&#363;n&#371;</name>
</response>

but when i parse value name i get only & as value. Is it allowed to use # or & in xml? or i have to use cdata necessarily?

但是当我解析值名时,我只得到& as值。是否允许在xml中使用#或& ?还是必须使用cdata ?

2 个解决方案

#1


15  

The & character appears to be illegal, use (below) instead.

与字符似乎是非法的,使用(下面)代替。

&amp;

Invalid Characters in XML

XML中存在非法字符

The # character should be OK.

#字符应该是OK的。

Also this may be useful: http://xml.silmaril.ie/specials.html.

这也可能是有用的:http://xml.silmaril.ie/specials.html。

#2


5  

& needs to be escaped as it is used for esaping itself. All escapes start with & (&quot;, &lt;, &gt;).

需要转义,因为它是用来保存自己的。所有转义都以&开头。

&amp; is the escape for &

,逃跑是为了& ?

#1


15  

The & character appears to be illegal, use (below) instead.

与字符似乎是非法的,使用(下面)代替。

&amp;

Invalid Characters in XML

XML中存在非法字符

The # character should be OK.

#字符应该是OK的。

Also this may be useful: http://xml.silmaril.ie/specials.html.

这也可能是有用的:http://xml.silmaril.ie/specials.html。

#2


5  

& needs to be escaped as it is used for esaping itself. All escapes start with & (&quot;, &lt;, &gt;).

需要转义,因为它是用来保存自己的。所有转义都以&开头。

&amp; is the escape for &

,逃跑是为了& ?