【问题标题】:Can an XMLDocument object be use with an XPathDocument object?XMLDocument 对象可以与 XPathDocument 对象一起使用吗?
【发布时间】:2011-04-25 10:11:48
【问题描述】:

我有一个转换 html 文件并返回 XMLDocument 对象的静态方法。

经过广泛研究,出现了以下问题:

可以将 XMLDocument 对象传递给 XPathDocument 对象,以便在从文档中读取数据而不是对其进行编辑时变得容易。

Research01

MSDN

请回复并告诉我这是否可能?如果有,怎么做?

干杯。

【问题讨论】:

  • 不查询为什么还需要XPathDocument?
  • 糟糕,错字...现在刚刚编辑。

标签: c# .net xml .net-3.5 xpathnavigator


【解决方案1】:

您如何从文档中读取数据? XmlDocumentXPathDocument 都有一个 CreateNavigator 方法,该方法返回一个 XPathNavigator 用于读取文档。否则,只需将XmlDocument 流式传输到MemoryStream 并从中创建XPathDocument

【讨论】:

  • 干杯老兄...我正在使用 SGMLReader 生成我的 XML 文档。每当我将它输入 XPathDocument 时,我都会得到一个根对象,其中所有 html 都传递到内部文本中,这对我来说没用:(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-01-05
  • 2010-12-29
  • 2012-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多