Full instance of ASP operation XML file

Source: Internet
Author: User

Introduction to

<%
'----------------------------------------------------------------
' procedures: Completing the increment of the specified node text in an XML document by the ASP language , delete, modify, view
' entry parameters: None
' exit parameter: No
'------------------------------------------------
' function name: Connectxml ()
' Entry parameter: filename requires a connection or Open XML filename
' exit parameter: None
' return value: Connectxml=0,xmlmorntekdocument is an object that successfully loads an XML document.
' connectxml<>0, print the error message 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 inserted element name
'           Befelementname inserts the element
'           elementtext the text of the inserted element
before the name of this element Exit parameters: No
'------------------------------------------------
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
%>

Turn from: Dynamic Network production guide www.knowsky.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.