nodes.Current.SetValue(“...”) 侥幸吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它不适用于您发布的两个节点,还是仅适用于其中一个? (如果是的话,它适用于哪一个,哪一个不适用?)
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?)