python 是 XML 中的有效字符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/998950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is  a valid character in XML?
提问by Mark Harrison
On this data:
在这个数据上:
<row Id="37501" PostId="135577" Text="...uses though."/>
I'm getting an error with the Python sax parser:
我在使用 Python sax 解析器时遇到错误:
xml.sax._exceptions.SAXParseException:
comments.xml:29776:332: reference to invalid character number
I trimmed the example; 332 points to "".
我修剪了这个例子;332 指向“"。
Is the parser correct in rejecting this character?
解析器拒绝这个字符是否正确?
回答by
As others have stated, you probably meant
. The reason why 
(0x10 = 10h = 16) is invalid is that it's explicitly excluded by the XML 1.0 standard: (http://www.w3.org/TR/xml/#NT-Char)
正如其他人所说,您的意思可能是
. 之所以
(0×10 = 10小时= 16)是无效的是,它明确地被排除XML 1.0标准:(http://www.w3.org/TR/xml/#NT-Char)
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
回答by Naaff
is the linefeed character, which seems to be the intent.
是换行符,这似乎是意图。

would be the same as 
(10 hex is 16 decimal) and would refer to the DLE (data link escape) character.

将与
(10 hex 是 16 十进制)相同,并指代 DLE(数据链接转义)字符。
DLE is a transmission control characterused to control the interpretation of data being transmitted.
DLE 是一个传输控制字符,用于控制传输数据的解释。