nodes.Current.SetValue(“...”) 侥幸吗?

发布于 2024-11-01 20:23:44 字数 2950 浏览 2 评论 0原文

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。之后打印就不行了。我在保存导航流之前特别重新选择了该节点,但仍然没有任何结果。 (实际上,它不是什么都。它似乎是空格,甚至可能是换行符。我不知道为什么在这种情况下它不起作用。下面是这些的相关 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 以保留空格。这似乎可以修复它输出空格和/或换行符,但该值仍然丢失。

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...

I use the nodes.Current.SetValue() function MANY times through this program, and it's only in this one instance (each time for this node) that it just doesn't want to work. With breakpoints, it will show the that node's innerXML reflects i as it's supposed to. Afterwards, printing it doesn't work. I reselected that node in particular before saving the nav stream and still nothing. (Actually, it isn't nothing. It seems to be spaces or possibly even a line feed. I have no idea why in this case it just doesn't work. Below is the pertinant XML for these two nodes.

<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>

I am so confused why this isn't working... Anybody have any ideas?

EDIT:
More information:
I changed the XMLDocument to preserve whitespace. This seems to fix it outputting spaces and/or a linefeed, but the value is still lost.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赤濁 2024-11-08 20:23:44

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

Is it not working for both of the nodes you posted, or just one of them? (If so, which one is it working for, and which one not?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文