cancel
Showing results for 
Search instead for 
Did you mean: 

Remove nodes XML

Former Member
0 Kudos

Hello, I have this XML "C:\entrega.xml" and I want to remove two nodes. HOW????

-


<?xml version="1.0" encoding="UTF-16" ?>

-<BOM>

--<BO>

-


<AdmInfo>

-


<Object>15</Object>

-


<Version>2</Version>

-


<Document_Lines>

-


<row>

-


<BaseType>17</BaseType>

-


<BaseEntry>27</BaseEntry> -> REMOVE

-


<BaseLine>0</BaseLine>

-


<ItemCode>10-01A</ItemCode>

-


<ItemDescription>ARTICULO</ItemDescription>

-


<Quantity>1.000000</Quantity>

-


<ShipDate>20051013</ShipDate>

-


<row>

-


<BaseType>17</BaseType>

-


<BaseEntry>27</BaseEntry> -> REMOVE

-


<BaseLine>1</BaseLine>

-


<ItemCode>10-01B</ItemCode>

-


<ItemDescription>ARTICULO2</ItemDescription>

-


<Quantity>2.000000</Quantity>

-


<ShipDate>20051013</ShipDate>

-


I need a curl and I haven`t idea.

Thanks.

-


Message was edited by: Santiago Albaladejo Aliaga

Message was edited by: Santiago Albaladejo Aliaga

Accepted Solutions (1)

Accepted Solutions (1)

rasmuswulff_jensen
Active Contributor
0 Kudos

Which programming language?

Former Member
0 Kudos

Ohhh, I`m sorry, VB 6.0.

Former Member
0 Kudos

Probably there are better or easier ways to to this, but following code is working for me (removing node "c"):

Public Sub Main()
    Dim i As Long
    Dim objXml As New MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMNode
    objXml.loadXML "<a><b><c/><d/></b></a>"
    Debug.Print objXml.xml
    Set objNode = objXml.selectSingleNode("a/b")
    For i = 0 To objNode.childNodes.length
        If objNode.childNodes(i).nodeName = "c" Then
            objNode.removeChild objNode.childNodes(i)
            Exit For
        End If
    Next
    Debug.Print objXml.xml
End Sub

Answers (0)