I have this xml :
<un:casamae Id="1">
<un:casafilha Id="1">
<xn:telhado id="without records">
</xn:telhado>
<xn:telhado id="without records" modifier="create">
<xn:composicao>
<xn:tipotelha>vermelho</xn:vsDataType>
<xn:numerotelhas>127</xn:vsDataFormatVersion>
<es:vermelho />
</xn:composicao>
</xn:telhado>
<xn:muro id=256 modifier="create">
</xn:muro>
</un:casafilha>
<un:casafilha Id="65501">
</un:casafilha>
I want this :
<un:casamae Id="1">
<un:casafilha Id="1">
<xn:muro id=256 modifier="create">
</xn:muro>
</un:casafilha>
<un:casafilha Id="65501">
</un:casafilha>
This is the code I have so far:
doc2.Load(folder_dest & "\xpto.xml")
For Each casafilha In casafihalist
Dim xpathstring2 = "un:casamae//un:casafilha[@Id=" & casafilha & "]"
Dim nodeselect2 As XmlNode = doc2.SelectSingleNode(xpathstring2, namespaces)
For Each node As XmlNode In nodeselect2.SelectNodes("//xn:telhado[@id='without records']", namespaces)
node.ParentNode.RemoveChild(node)
Next
Next casafilha
doc2.Save(folder_dest & "\xpto.xml")
The problem:
I've tried several solutions, but so far, I just being able of deleting the first chid xml with the "id" atribute equals "without records", leaving always the one with the id="without records" and modifier="create" behind.
How can I delete any kind of telhado id="without records" and their own subelements?