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
If ele IsNot Nothing Then
strAffInnerText = strAffInnerText & ele.InnerText
affiliationElement.RemoveChild(ele)
End If
Next
会出错:没有进行循环,因为有 affiliationElement.RemoveChild(ele)这句话,删掉就可以了,原因还不是很清楚???!!!
若不删除ffiliationElement.RemoveChild(ele)这句话,需在循环前面重新选取nodeList,如下:
dim eleNodeLst as xml.xmlNodeList
eleNodeLst =affiliactionEleMent.selectNodes("./*")
但是这样的eleNodeLst 不包含文本节点!
原文链接:https://www.f2er.com/vb/258740.html