【问题标题】:nodes.Current.SetValue("...") fluke?nodes.Current.SetValue("...") 侥幸?
【发布时间】:2011-04-18 23:28:22
【问题描述】:
XPathNodeIterator nodes = nav.Select("//d:page/d:field/d:value", nsmgr);

...do stuff..

nodes.MoveNext();
nodes.Current.SetValue(i.ToString()); //<-HERE!
nodes.MoveNext();
nodes.Current.SetValue(numPages.ToString());

..do more stuff...

我在这个程序中多次使用nodes.Current.SetValue() 函数,并且只有在这个实例中(每次都针对这个节点)它只是不想工作。使用断点,它将显示该节点的 innerXML 反映了i,因为它应该是。之后,打印它不起作用。在保存导航流之前,我特别重新选择了该节点,但仍然没有。 (实际上,它不是 nothing。它似乎是空格,甚至可能是换行符。我不知道为什么在这种情况下它不起作用。下面是这些的相关 XML两个节点。

<field sid="PAGE">
      <itemlocation>
        <ae>
          <ae>absolute</ae>
          <ae>1051</ae>
          <ae>899</ae>
        </ae>
        <ae>
          <ae>extent</ae>
          <ae>47</ae>
          <ae>24</ae>
        </ae>
      </itemlocation>
      <value>
      </value>
      <borderwidth>0</borderwidth>
      <fontinfo>
        <ae>Times New Roman</ae>
        <ae>10</ae>
        <ae>plain</ae>
      </fontinfo>
      <justify>center</justify>
      <scrollhoriz>wordwrap</scrollhoriz>
      <scrollvert>fixed</scrollvert>
      <format>
        <ae>string</ae>
        <ae>optional</ae>
      </format>
      <next>OFPG</next>
      <previous>QTYFA_15</previous>
      <acclabel>asterisk.  when used as a.
hand receipt, enter hand receipt annex number.
hand receipt for quarters furniture, enter condition codes.
hand receipt annex or components receipt, enter accounting requirements code, ay r c.
enter page number.</acclabel>
    </field>
    <field sid="OFPG">
      <itemlocation>
        <ae>
          <ae>absolute</ae>
          <ae>1129</ae>
          <ae>899</ae>
        </ae>
        <ae>
          <ae>extent</ae>
          <ae>35</ae>
          <ae>24</ae>
        </ae>
      </itemlocation>
      <value>4</value>
      <borderwidth>0</borderwidth>
      <fontinfo>
        <ae>Times New Roman</ae>
        <ae>10</ae>
        <ae>plain</ae>
      </fontinfo>
      <justify>center</justify>
      <scrollhoriz>wordwrap</scrollhoriz>
      <scrollvert>fixed</scrollvert>
      <format>
        <ae>string</ae>
        <ae>optional</ae>
      </format>
      <previous>PAGE</previous>
      <next>NEXT_BUTTON</next>
      <acclabel>enter total number of pages.</acclabel>
    </field>

我很困惑为什么这不起作用...有人有什么想法吗?

编辑: 更多信息: 我更改了 XMLDocument 以保留空格。这似乎修复了它输出空格和/或换行符,但该值仍然丢失。

【问题讨论】:

    标签: c# .net xml xpathnodeiterator


    【解决方案1】:

    它不适用于您发布的两个节点,还是仅其中一个? (如果是这样,它适用于哪一个,而不适用于哪一个?)

    【讨论】:

    • 它不适用于第一个 。它适用于第二个,以及文档中的数百个其他 。那是/是我开始保留空白之前的输出结果。现在它只是空的......
    • 嗯,这令人费解。我在两个节点之间看到的唯一区别(可能无关紧要)是“上一个”和“下一个”子节点的顺序。
    • 好吧。很高兴我不是唯一一个被它难倒的人。看样子,还有45人也被难住了。感谢您的输入。下一步是在阳光下尝试一切,以获得那里的价值。幸运的是,这可能是我正在使用的文档中最不重要的字段。还是很烦……
    • 出于好奇,没有被塞进那个的值是什么?
    猜你喜欢
    • 1970-01-01
    • 2020-09-09
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    • 2012-03-04
    相关资源
    最近更新 更多