我正在使用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