[已解决]结合使用XmlTextReader的开始和结束标签 [英] [Solved] combined start and end tags with XmlTextReader

查看:66
本文介绍了[已解决]结合使用XmlTextReader的开始和结束标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然它不是有效的XHTML,但许多XML仍使用< foo>构造.但是,当我使用XmlTextReader读取此元素时,我得到的是Element的节点类型,没有任何迹象表明它也是EndElement.有什么办法可以解决吗?

OP更新:
您可以检查reader.IsEmptyElement,如果它是一个自动关闭的标签,则为true,否则为false.

While it''s not valid XHTML, lots of XML still use the <foo> construct. But when I use XmlTextReader to read this element, I get a nodetype of Element, with no indication that it''s also and EndElement. Is there any way to deal with this?

UPDATE from OP:
You can check reader.IsEmptyElement, and if it''s a self-closing tag it''s true, false otherwise.

推荐答案

内部,我不知道以为是,我认为它仍然可以分开,所以下一个节点是结束节点.
Internally, I don''t think that it is, I think that it still seperates it so the next node is the end node.


好,我找到了答案.您可以检查reader.IsEmptyElement,如果它是一个自动关闭的标签,则为true,否则为false.
OK, I found the answer. You can check reader.IsEmptyElement, and if it''s a self-closing tag it''s true, false otherwise.


这篇关于[已解决]结合使用XmlTextReader的开始和结束标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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