[英]Write XmlReader XML to immediate window in Visual Studio?
How can the XML
contained in an XmlReader
instance be written to the immediate window in Visual Studio? 如何将XmlReader
实例中包含的XML
写入Visual Studio中的即时窗口? Seems like ToString()
would do the trick, but it doesn't... 看起来像ToString()
会做的伎俩,但它不...
Do you want to debug XmlReader? 你想调试XmlReader吗? From my experience it's easier to give up. 根据我的经验,它更容易放弃。
Dispite that you can call XDocument.Load(reader).ToString()
what will read the reader to its end thus make it further unusable. 尽管你可以调用XDocument.Load(reader).ToString()
,读者会读到它的内容,从而使它更加无法使用。 However you can initialize a new reader from resulting document. 但是,您可以从结果文档初始化新的阅读器。 To make it easier write a helper method. 为了便于编写辅助方法。
Try this: 尝试这个:
reader.MoveToContent();
reader.ReadOuterXml();
But be aware that the XmlReader will not be usable any more. 但请注意,XmlReader将不再可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.