为什么我使用.net的XMLWriter创建的每个XML文件都无法通过W3C验证?

时间:2012-02-16 21:11:41

标签: .net vb.net xmlwriter

W3C验证员告诉我

Line 256, Column 12: non SGML character number 0

两个错误都发生在文件的最后。

这是我的缩写代码:

            dim writer as XmlWriter
            dim xmlSettings as new XmlWriterSettings
            xmlSettings.Encoding = Encoding.UTF8
            xmlSettings.CheckCharacters = true
            xmlSettings.ConformanceLevel = ConformanceLevel.Document
            xmlSettings.Indent = true

            writer = XmlWriter.Create("D:\somedata.xml", xmlSettings)

            writer.WriteStartDocument()
            writer.WriteStartElement("listings")

            while invReader.Read( )

                writer.WriteStartElement("listing")

                'a bunch of .writeElementString calls here

                writer.WriteEndElement()
            end while       
            writer.WriteEndElement()
            writer.WriteEndDocument()
            writer.Close()

1 个答案:

答案 0 :(得分:0)

看起来你正试图写出验证者认为非法的字符

请查看此链接以获取错误示例:

http://forums.htmlhelp.com/index.php?showtopic=11270