Hi,
Here i've written a function for deleting a specific node from the xml file.
As you've asked, this function accepts a string as arguments (in your case it is the string "Hello"), the function searches
for the given string in a particular node (here it is node "c2"). if a matching node is found, it will be deleted from the
xml document and document gets saved.
the function will return true or false based on the operation done
here i've used XPATH queries to search the nodes in the xml document (one of the fastest way)
hope this function would help solve your problem
function deleteXMLNode(strText)
Dim xmlDoc, xmlNode
Dim bDeleted
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.Load Server.MapPath("system\settings.xml")
Set xmlNode = xmlDoc.selectSingleNode("a/b[c2='" & Trim(strText) & "']")
If Not xmlNode Is Nothing Then
xmlDoc.documentElement.removeChild xmlNode
bDeleted = True
Else
bDeleted = False
End If
xmlDoc.Save Server.MapPath("system\settings.xml")
deleteXMLNode = bDeleted
end function
Regards,
Raghu
|