を使用してXmlReader
取得したものを使用していますSqlCommand.ExecuteXmlReader
。
このコード行を実行すると、次のようになります。
XDocument currentXDoc = XDocument.Load(ktXmlReader.ReadSubtree());
初めて動作し、期待どおりに最初のProductノードを読み取ります。
2回目に実行すると、次の例外が発生します。
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)
私はこの質問と私の質問に似ていることを見つけましたが、私のXMLは整形式であるとかなり確信しています(sprocを実行することで直接取得できます)
これまでの私の考え:
- 2048は、コンピューターでは非常に疑わしい数値です。
XDocument
またはどこかで2KBの制限に遭遇していますかXmlReader
? - whileループのktXmlReader.Read()は、他のすべてのノードをスキップしてEOFに直接移動しています。