C#:与XmlDocument的解析XML时线信息 [英] C#: Line information when parsing XML with XmlDocument

查看:145
本文介绍了C#:与XmlDocument的解析XML时线信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有哪些用于解析XML文件,XmlDocument的仍然保留行信息的错误消息以后选择? (顺便说一句,是有可能做同样的事情XML Deserialisation?)

What are my options for parsing an XML file with XmlDocument and still retain line information for error messages later on? (as an aside, is it possible to do the same thing with XML Deserialisation?)

选择似乎包括:

  • Extending the DOM and using IXmlLineInfo
  • Using XPathDocument

推荐答案

我知道的唯一的其他选择是 XDocument.Load(),其重载接受 LoadOptions.SetLineInfo 。这将在大致相同的方式被消耗作为的XmlDocument

The only other option I know of is XDocument.Load(), whose overloads accept LoadOptions.SetLineInfo. This would be consumed in much the same way as an XmlDocument.

这篇关于C#:与XmlDocument的解析XML时线信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆