XmlNodeReader.Skip方法无法按预期工作 [英] XmlNodeReader.Skip Method not working as expected

查看:53
本文介绍了XmlNodeReader.Skip方法无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试跳过xml文档中的元素,其中style属性为VISIBILITY:hidden或DISPLAY:none。


在下面的例子中,我想跳过最后两个元素,但是当我跳过id =?Div1的元素时?

和下一个reader.Read()读取?包括我?但我希望它能读取元素< a id =" Div2" style =" visibility:hidden">而不是它的写作?包括我?到控制台

示例xml

I am trying to skip element in xml document where style attribute is VISIBILITY: hidden or DISPLAY: none.

In the following example i want to skip the last two elements but when i skip the element with id=?Div1?
and next reader.Read() reads ? includeme? but i expected it to read element <a id ="Div2" style="visibility:hidden "> and skip it instead its writing ? includeme? to the console

sample xml

展开 | 选择 | Wrap | 行号

推荐答案

在我看来,你的代码正在做它应该做的事情。

你告诉它跳过具有可见性的节点:隐藏或显示:无

所以它跳过了你的< div>和< a3>标签。

并且到达文本标签includeme它被告知要打印出来。

虽然我也希望它能打印出其他第一字样。和其他第二太。 (根据你的console.writeline())


编辑:在那个说明中,我认为它会打印出文件中的空白区域。
Seems to me your code is doing exactly what it should do.
You tell it to skip nodes that have visibility:hidden or Display:none
So it skips your <div> and <a3> tag.
And arrives at the text tag "includeme" which it is told to print out.
Although I would also expect it to print out "other first" and "other second" too. (According to your console.writeline() )

On that note, I would think it would print out the whitespace you have in the file too.



在我看来,你的代码正在做它应该做的事情。

你告诉它跳过具有可见性的节点:隐藏或显示:无

因此它会跳过你的< div>和< a3>标签。

并且到达文本标签includeme它被告知要打印出来。

虽然我也希望它能打印出其他第一字样。和其他第二太。 (根据你的console.writeline())


编辑:在那个说明中,我认为它会打印出文件中的空白。
Seems to me your code is doing exactly what it should do.
You tell it to skip nodes that have visibility:hidden or Display:none
So it skips your <div> and <a3> tag.
And arrives at the text tag "includeme" which it is told to print out.
Although I would also expect it to print out "other first" and "other second" too. (According to your console.writeline() )

On that note, I would think it would print out the whitespace you have in the file too.



其打印其他第一和其他第二但我想跳过includeme因为< a3>的元素值也是如此。我希望跳过< a3>内的所有子节点的标签element。


Its printing "other first" and "other second" but i want to skip "includeme" as well because its element value of <a3> tag which i want to skip all the child nodes inside <a3> element.



它的打印其他第一个和其他第二但我想跳过includeme因为< a3>的元素值也是如此。我希望跳过< a3>内的所有子节点的标签元件。
Its printing "other first" and "other second" but i want to skip "includeme" as well because its element value of <a3> tag which i want to skip all the child nodes inside <a3> element.



嗯,这不是你写的代码,你没有跳过第一个。和第二节点,即使它们是< div>的子节点应该跳过的标签。

我认为你需要去下一个sibbling,而不是下一个孩子。不确定树逻辑是否属于树逻辑。这里是正确的,但似乎是跳过只是移动到下一个节点,无论它是小孩还是傻瓜(甚至是后退向上)

Well that''s not the code you have written, you''re not skipping the "first" and "second" nodes either, even though they are children of the <div> tag that should be skipped.
I think you need to go to next sibbling, and not next child. Not sure if "tree logic" is correct here, but it seems like "skip" just moves to the next node, regardless of if it''s a child or a sibbling (or even a step back "up")


这篇关于XmlNodeReader.Skip方法无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆