vb.net中用Xpath遍历子节点的问题
xml文档的一部分: <affiliation OID="" CNY="" TYPE="ORG"> <orgDiv>Department of Molecular Neuroscience,UCL Institute of Neurology</orgDiv> <label type="remove" bsType="remove">,</label> <address><city>London</city><label type="remove" bsType="remove">,</label><country>UK</country></address> aaaaaaaaaaaaa </affiliation> 当使用xmlNodeList是,其中是包含文本节点的,即“affiliation”的子节点有5个“aaaaaaaaaaaaa”也算是一个节点, 但是xmlElement就只能是有尖括号的如<orgDiv> 进行遍历的时候 dim ele as xml.xmlElement For Each ele In affiliationElement.ChildNodes 会出错:没有进行循环,因为有 affiliationElement.RemoveChild(ele)这句话,删掉就可以了,原因还不是很清楚???!!! 若不删除ffiliationElement.RemoveChild(ele)这句话,需在循环前面重新选取nodeList,如下: dim eleNodeLst as xml.xmlNodeList eleNodeLst =affiliactionEleMent.selectNodes("./*")
但是这样的eleNodeLst 不包含文本节点! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |