.NET的XmlDocument的loadXML和实体 [英] .NET XmlDocument LoadXML and Entities

查看:327
本文介绍了.NET的XmlDocument的loadXML和实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当加载XML到XmlDocument,即

When loading XML into an XmlDocument, i.e.


XmlDocument document = new XmlDocument();
document.LoadXml(xmlData);



有没有什么办法阻止取代实体的过程?我有一个奇怪的问题,我已经有了一个TM符号(存储为实体#8482)在XML被转换成字符TM。至于我而言这不应该发生的XML文档的编码ISO-8859-1(它没有TM符号)

is there any way to stop the process from replacing entities? I've got a strange problem where I've got a TM symbol (stored as the entity #8482) in the xml being converted into the TM character. As far as I'm concerned this shouldn't happen as the XML document has the encoding ISO-8859-1 (which doesn't have the TM symbol)

谢谢

推荐答案

这是XML工具集的标准误解。整个业务&安培;#X,是一种语法功能设计,以应付字符编码。你的XmlDocument不是字符流 - 它已释放的字符编码​​问题 - 而是它包含XML类型数据的抽象模型。对于这句话包括DOM和信息集,我不知道到底哪个是准确的。

This is a standard misunderstanding of the XML toolset. The whole business with "&#x", is a syntactic feature designed to cope with character encodings. Your XmlDocument isn't a stream of characters - it has been freed of character encoding issues - instead it contains an abstract model of XML type data. Words for this include DOM and InfoSet, I'm not sure exactly which is accurate.

&放大器;#X,因为整个问题是无关格宾斯不会在这种模式存在,它将返回 - 如果相应的 - 当你变换的信息集回在一些特定的编码字符流。

The "&#x" gubbins won't exist in this model because the whole issue is irrelevant, it will return - if appropriate - when you transform the Info Set back into a character stream in some specific encoding.

这误会足够常见的有使它成为学术文献类似的怪癖的集合的一部分。看看的Xml热在这个位置: http://doi.acm.org/10.1145/1364782.1364795

This misunderstanding is sufficiently common to have made it into academic literature as part of a collection of similar quirks. Take a look at "Xml Fever" at this location: http://doi.acm.org/10.1145/1364782.1364795

这篇关于.NET的XmlDocument的loadXML和实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆