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以保留空白。这似乎修复了它输出空格和/或行提要,但它的值仍然丢失。
发布于 2011-04-19 17:55:47
它不是对您发布的两个节点都有效,还是只对其中一个节点起作用?(如果是,它在为哪一个工作,哪一个不工作?)
https://stackoverflow.com/questions/5709988
复制相似问题