Copy Code code as follows:
<%
'----------------------------------------------------------------
' Introduction: Complete the ASP language to add, delete, modify, view the text of the specified node in the XML document
' Entry parameters: None
' Exit Parameters: None
'------------------------------------------------
' Function name: Connectxml ()
' Entry parameter: FileName required to be connected or opened by XML filename
' Exit Parameters: None
' Return value: Connectxml=0,xmlmorntekdocument is an object that successfully loads an XML document.
' Connectxml<>0, the error message is printed strerror
'------------------------------------------------
Dim xmlmorntekdocument
function connectxml (filename)
Dim strsourcefile
strSourceFile = Server.MapPath (filename)
Set xmlmorntekdocument = Server.CreateObject ("Microsoft.XMLDOM")
Xmlmorntekdocument.async = False
Xmlmorntekdocument.load (strSourceFile)
Connectxml=xmlmorntekdocument.parseerror.errorcode
If Xmlmorntekdocument.parseerror.errorcode<>0 Then
Strerror= "strerror=strerror&xmlmorntekdocument.parseerror.reason& "<br>"
strerror=strerror&xmlmorntekdocument.parseerror.url& "<br>"
strerror=strerror&xmlmorntekdocument.parseerror.line& "<br>"
strerror=strerror&xmlmorntekdocument.parseerror.filepos& "<br>"
strerror=strerror&xmlmorntekdocument.parseerror.srctext& "<br>"
Response.Write strerror
End If
End Function
'------------------------------------------------
' Function name: Closexml ()
' Entry parameters: None
' Exit Parameters: None
'------------------------------------------------
function Closexml (xmlmorntekdocument)
If IsObject (xmlmorntekdocument) Then
Set xmlmorntekdocument=nothing
End If
End Function
'------------------------------------------------
' Function name: Selectxmlnodetext (elementname)
' Entry parameter: The name of the elementname element
' Exit Parameters: None
'------------------------------------------------
function Selectxmlnodetext (elementname)
Elementname= "//" &elementname
Temp=xmlmorntekdocument.selectsinglenode (elementname). Text
selectxmlnodetext= Server.HTMLEncode (temp)
End Function
'------------------------------------------------
' Function name: Insertxmlnodetext (Befelementname,elementname,elementtext)
' Entry parameter: ElementName the name of the inserted element
' Befelementname inserts an element before the name of this element
' Elementtext the text of the inserted element
' Exit Parameters: None
'------------------------------------------------
function Insertxmlnodetext (befelementname,elementname,elementtext)
Dim befelement,element
Set Befelement=xmlmorntekdocument.selectsinglenode ("//" &befelementname)
Set element= xmlmorntekdocument.createelement (elementname)
Befelement.insertbefore Element,befelement.firstchild
Element.text=elementtext
End Function
'------------------------------------------------
' Function name: Updatexmlnodetext (Elementname,newelementtext)
' Entry parameter: The name of the elementname element
' New text for newelementtext element
' Exit Parameters: None
'------------------------------------------------
function Updatexmlnodetext (elementname,newelementtext)
Dim element
Set Element=xmlmorntekdocument.selectsinglenode ("//" &elementname)
Element.text=newelementtext
End Function
'------------------------------------------------
' Function name: Deletexmlnodetext (elementname)
' Entry parameter: The name of the elementname element
' Exit Parameters: None
'------------------------------------------------
function Deletexmlnodetext (elementname)
Xmlmorntekdocument.selectsinglenode ("//" &elementname). Text = ""
End Function
%>