首页 > 其他 > 详细

修复使用<code>XmlDocument</code>加载含有DOCTYPE的Xml时,加载后增加“[]”字符的错误

时间:2017-04-19 09:30:19      阅读:343      评论:0      收藏:0      [点我收藏+]

C# LINQ TO XML - Remove “[]” characters from the DTD header

http://stackoverflow.com/questions/12358061/c-sharp-linq-to-xml-remove-characters-from-the-dtd-header

        public static void FixDocumentType(this XmlDocument xml)
        {
            if (xml?.DocumentType == null)
                return;
            var name = xml.DocumentType.Name;
            var publicId = xml.DocumentType.PublicId;
            var systemId = xml.DocumentType.SystemId;
            var parent = xml.DocumentType.ParentNode;
            var documentTypeWithNullInternalSubset = xml.CreateDocumentType(name, publicId, systemId, null);
            if (parent == null || xml.DocumentType == null)
                return;
            parent.ReplaceChild(documentTypeWithNullInternalSubset, xml.DocumentType);
        }

  

修复使用<code>XmlDocument</code>加载含有DOCTYPE的Xml时,加载后增加“[]”字符的错误

原文:http://www.cnblogs.com/maozhh/p/6731581.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!