[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
xml remove node
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.