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

RE: Remove node in xml file from Visual Basic?

Subject: RE: Remove node in xml file from Visual Basic?
From: Ben Robb <Ben@xxxxxxxxxx>
Date: Thu, 13 Apr 2000 13:41:03 +0100
removechild visual basic
It was a little off-topic, but since I know the answer, I'll post it anyway
*grin* For future reference, there is an XML Discussion list at 15seconds
(xml@xxxxxxxxxxxxxxxxxx) which would be more appropriate for this question.


I would do it something like this (basically you need to use the parentNode
method):

+++++++++++++++++++++++++
Set objNodeList = xmldoc.getElementsByTagName("gen_date")

for each datenode in objNodeList

' put in all of the date formating stuff
	If Tmp_Date = Del_Dato Then
		' get the parent (i.e. the <bb> tag)
		Set objParent = datenode.parentNode
		' remove it from the document
		xmldoc.documentElement.removeChild(objParent)
	end if
next
++++++++++++++++++++++++++

This will work because objParent is a pointer to a specific node on the
tree, and so the removeChild method will know which node to remove.

A neater way of doing it, since you are using the MSXML DOM, is to do this
(where trans_date is del_date converted to the correct format for comparing
with the xml):

+++++++++++++++++++++++++++++++++++++++++++
Set objNodeList = xmldom.documentElement.selectNodes("//bb[gen_date/text() =
'" & trans_date & "']")

For each objNode in objNodeList
	xmldoc.documentElement.removeChild(objNode)
Next

++++++++++++++++++++++++++++++++++++++++++

and then save it back to the file system.

Rgs,

Ben


 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.