[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?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|