【问题标题】:How can I get an xmlnode from xmlnodereader如何从 xmlnodereader 获取 xmlnode
【发布时间】:2011-04-04 18:56:35
【问题描述】:

我正在将 icecat 表作为一个巨大的 xml 文档 (1.7g) 阅读,并且我正在使用 xmlnodereader。

如何逐个节点读取它。我知道,通常情况下,你不会这样做,但结构看起来像

<file attr=value>...</file>


<file attr=value>...</file>


<file attr=value>...</file>


<file attr=value>...</file>


<file attr=value>...</file>

这是一些现有的代码供参考:

 foreach (BackgroundWorker worker in Pool)
            {
                if (worker.IsBusy)
                    continue;
                //read xmlnode and pass it to the worker

            }

【问题讨论】:

    标签: c# xml xmlnode


    【解决方案1】:

    如果可以的话,我建议使用 LINQ to XML。您可以使用:

    XElement element = XElement.Load(reader);
    

    它只会从阅读器加载单个元素,并适当地推进它。这真的很容易做到,而且 LINQ to XML API 比旧的 DOM API 要好得多。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-19
      • 1970-01-01
      • 2021-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多