Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie..Help for deleteing XML Nodes???

Status
Not open for further replies.

glebreck

IS-IT--Management
Nov 20, 2002
34
US
I have an xml file:
<?xml version="1.0" encoding="UTF-8"?>
<SIMPLEVIEWER_DATA>
<IMAGE>
<NAME>doph.jpg</NAME>
</IMAGE>
<IMAGE>
<NAME>dragonfly_tattoo.jpg</NAME>
</IMAGE>
<IMAGE>
<NAME>images.jpg</NAME>
</IMAGE>
<IMAGE>
<NAME>Maori-Tattoos.jpg</NAME>
</IMAGE>
<IMAGE>
<NAME>tattoos.jpg</NAME>
</IMAGE>
<IMAGE>
<NAME>Cruiser_image.jpg</NAME>
</IMAGE>
</SIMPLEVIEWER_DATA>
I am passing a querystring from an asp page called "NAME"
and I want to be able to delete the Image Node where the Child Node has the same innertext as the query string.

Is this possible.
 
Something like this, or with your own expansion and variations, might do?
[tt]
dim xmlfile, simg, oparser, onode

xmlfile=server.mappath("abc.xml") 'your input
simg=request.form("name") 'or from querystring whatever

set oparser=server.createobject("msxml2.domdocument")
with oparser
.async=false
.validateOnParse=false
.resolveExternals=false
.load xmlfile
end with

set onode=oparser.selectSingleNode("//NAME[text()="""+simg+"""]")
if not (onode is nothing) then
onode.parentNode.parentNode.removeChild onode.parentNode
oparser.save xmlfile
end if

set onode=nothing
set oparser=nothing
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top