<% '----------------------------------------------- ----------------- '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 = "
'------------------------------------------------' 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