我正在使用SqlCommand.ExecuteXmlReader
检索到的XmlReader
。System.Xml.XmlException:解析时文件意外结束发生名称
当我运行这行代码:
XDocument currentXDoc = XDocument.Load(ktXmlReader.ReadSubtree());
它工作在第一时间,第一产品节点读取预期。
运行第二次,我得到以下异常:
System.Xml.XmlException:
Message: Unexpected end of file while parsing Name has occurred. Line 1, position 2048.
Stacktrace: at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
at System.Xml.XmlTextReaderImpl.ParseEndElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlSubtreeReader.Read()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
我确实发现this question和this question这是与我相似,但我相当肯定是格式良好的XML我(我可以直接从运行一个存储过程)
我的想法而已获得它:
- 2048是电脑一个非常可疑的号码。我在
XDocument
或XmlReader
的某处遇到2KB的限制吗? - 我ktXmlReader.Read()在while循环以某种方式跳过所有其他节点,而直接进入到EOF
http://forums.asp.net/t/1191911.aspx – Codeman 2013-03-19 19:18:02