ASP Operation XML file full instance

zhaozj2021-02-16  171

<% '----------------------------------------------- ----------------- 'Program Description: Complete the increase, delete, modification of the specified node text in the XML document to the XML document: No' export parameters: no ' ---------------------------------------------- 'functions Name: ConnectXML () 'Entry Parameters: FileName XML File Name' Exit Parameters: No 'Return Value: ConnectXML = 0, XMLMorntekDocument is an object that successfully loads an XML document. 'ConnectXML <> 0, print error message strrror' ------------------------------------ ---------- 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 = "

error" & XMLMorntekDocument.parseerror.errorcode & "" strError = strError & XMLMorntekDocument.parseerror.reason & "
" strError = strError & XMLMorntekDocument.parseerror.url & "
" strError = strError & XMLMorntekDocument.parseerror.line & "
" strError = strError & XMLMorntekDocument.parseerror.filepos & "
" strError = strError & XMLMorntekDocument.parseerror.srcText & "
" response.write strError end if end function

'------------------------------------------------' Function name: closexml () 'entry parameters: no' export parameters: no '--------------------------------- --------------- Function Closexml (XMLMorntekDocument) IF IsObject (XMLMorntekDocument) THEN SET XMLMORNTEKDocument = Nothing end if End function

'------------------------------------------------' Function name: selectxmlNodeText (ElementName) 'ElementName Elements' Name 'Exit Parameters: No' ----------------------------- ------------------- function selectXmlNodeText (elementname) elementname = "//" & elementname temp = XMLMorntekDocument.selectSingleNode (elementname) .text selectXmlNodeText = server.htmlencode (temp) end Function

'------------------------------------------------' Function Name: INSERTXMLNODETEXT (BefeelementName, ElementName, ElementText) 'ElectName: ElementName Inserted Elements' BefElementName In front of this element in front of this element' ElementText Insert element text '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 Parameters: ElementName Elements' Name' New WenlementText Elements New Text 'Exit Parameters: No' --------------------- --------------------------- Function UpdatexmlNodeText (ElementName, NewElementText) Dim Element Set Element = XMLMorntekDocument.selectsinglenode ("//" & elementname) Element .text = newElementText end function

转载请注明原文地址:https://www.9cbs.com/read-7826.html

New Post(0)