Remove node in xml file from Visual Basic?

Subject: Remove node in xml file from Visual Basic?
From: "Paal Eriksen" <pserik@xxxxxxxxxxx>
Date: Thu, 13 Apr 2000 12:54:08 CEST
I have a question about how to remove a node in a xml tree from VB6.

xml code is like this:

<a>
 <aa>
    <gen_date>13.4.2000</gen_date>
    <name>blablabla</name>
 </aa>
 <aa>
    <gen_date>12.4.2000</gen_date>
    <name>lablablab</name>
 </aa>
</a>

So what i do is getting the gen_date (12.4.2000) and i've solved how to delete only that but what i want to do is to delete it's parent to that particular date, which is <aa>

Result should then be

<a>
 <aa>
    <gen_date>13.4.2000</gen_date>
    <name>blablabla</name>
 </aa>
</a>

Here is the Visual Basic Code:

Dim xmldoc
Dim Check, Tmp_Date, Del_Date As String
Dim Ant, x As Integer
Del_Date = "12.4.2000"
Set xmldoc = CreateObject("Microsoft.XMLDOM")
xmldoc.async = False
xmldoc.Load ("f:\Data.Xml")
Set SlettNode = xmldoc.getElementsByTagName("gen_date")
Ant = SlettNode.length
For x = 0 To Antall - 1
   Tmp_Date = SlettNode.Item(x).nodetypedvalue
   Tmp_Date = RTrim(Left(Tmp_Dato, 10))
   If Mid(Tmp_Date, 2, 1) = "." And Mid(Tmp_Date, 4, 1) = "." Then
       Tmp_Date = RTrim(Left(Tmp_Date, 9))
   End If
   If Tmp_Date = Del_Dato Then
       Set OldChild = SlettNode.Item(x).firstchild
       SlettNode.Item(x).RemoveChild OldChild
   End If
Next x
xmldoc.save ("f:\Data.Xml")

Thanks

Paal Steven
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread