vbs类自带xml文件有哪些-创新互联

这篇文章主要介绍vbs类自带xml文件有哪些,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

为汉源等地区用户提供了全套网页设计制作服务,及汉源网站建设行业解决方案。主营业务为网站设计制作、成都网站建设、汉源网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

vbs类自带的xml文件有两种:
objXML.asp:测试文件
clsXML.asp:vbs类文件
代码:

objXML.asp
<%@ Language=VBScript %><% Option Explicit %><!--#INCLUDE FILE='clsXML.asp'--><%Dim objXML, strPath, strSet objXML = New clsXML
strPath = Server.MapPath('.') & '\New.xml'
objXML.createFile strPath, 'Root''Or If using an existing XML file:'objXML.File = 'C:\File.xml'
objXML.createRootChild 'Images'
'Here only one attribute is added to the Images/Image NodeobjXML.createChildNodeWAttr 'Images', 'Image', 'id', '1'objXML.updateField 'Images//Image[@id=1]', 
'super.gif'objXML.createRootNodeWAttr 'Jobs', Array('Size', 'Length', 'Width'), _Array(24, 31, 30)objXML.createRootNodeWAttr 'Jobs', 
Array('Size', 'Length', 'Width'), _Array(24, 30, 29)objXML.createRootNodeWAttr 'Jobs', Array('Size', 'Length', 'Width'), _Array(24, 31, 85)
'Notice that all three job nodes have size 24, all of those 'nodes will be updatedobjXML.updateField 'Jobs[@Size=24]', '24's'
'Notice that only two nodes have the specified XPath, hence 'only two new child nodes will be addedobjXML.createChildNodeWAttr 'Jobs[@Size=24 and @Length=31]', 
'Specs', _Array('Wood', 'Metal', 'Color'), _Array('Cedar', 'Aluminum', 'Green')
'It is always important to iterate through all of the nodes'returned by this XPath query.For Each str In objXML.getField('Jobs[@Size=24]')Response.
Write(str & '<br>')NextSet objXML = Nothing
Response.Redirect 'New.xml'%>
clsXML.asp:
<%Class clsXML'strFile must be full path to document, ie C:\XML\XMLFile.XML'objDoc is the XML ObjectPrivate strFile, objDoc
'*********************************************************************' Initialization/Termination'*********************************************************************
'Initialize Class MembersPrivate Sub Class_Initialize()strFile = ''End Sub
'Terminate and unload all created objectsPrivate Sub Class_Terminate()Set objDoc = NothingEnd Sub
'*********************************************************************' Properties'*********************************************************************
'Set XML File and objDocPublic Property Let File(str)Set objDoc = Server.CreateObject('Microsoft.XMLDOM')objDoc.async = FalsestrFile = strobjDoc.Load strFileEnd Property
'Get XML FilePublic Property Get File()File = strFileEnd Property
'*********************************************************************' Functions'*********************************************************************
'Create Blank XML File, set current obj File to newly created filePublic Function createFile(strPath, strRoot)Dim objFSO, objTextFileSet objFSO = Server.
CreateObject('Scripting.FileSystemObject')Set objTextFile = objFSO.CreateTextFile(strPath, True)objTextFile.WriteLine('<?xml version=''1.0''?>')objTextFile.
WriteLine('<' & strRoot & '/>')objTextFile.CloseMe.File = strPathSet objTextFile = NothingSet objFSO = NothingEnd Function
'Get XML Field(s) based on XPath input from root nodePublic Function getField(strXPath)Dim objNodeList, arrResponse(), iSet objNodeList = objDoc.documentElement.
selectNodes(strXPath)ReDim arrResponse(objNodeList.length)For i = 0 To objNodeList.length - 1arrResponse(i) = objNodeList.item(i).
TextNextgetField = arrResponseEnd Function
'Update existing node(s) based on XPath specsPublic Function updateField(strXPath, strData)Dim objFieldFor Each objField In objDoc.documentElement.
selectNodes(strXPath)objField.Text = strDataNextobjDoc.Save strFileSet objField = NothingupdateField = TrueEnd Function
'Create node directly under rootPublic Function createRootChild(strNode)Dim objChildSet objChild = objDoc.createNode(1, strNode, '')objDoc.documentElement.
appendChild(objChild)objDoc.Save strFileSet objChild = NothingEnd Function
'Create a child node under root node with attributesPublic Function createRootNodeWAttr(strNode, attr, val)Dim objChild, objAttrSet objChild = objDoc.
createNode(1, strNode, '')If IsArray(attr) And IsArray(val) ThenIf UBound(attr)-LBound(attr) <> UBound(val)-LBound(val) ThenExit FunctionElseDim iFor 
i = LBound(attr) To UBound(attr)Set objAttr = objDoc.createAttribute(attr(i))objChild.setAttribute attr(i), val(i)NextEnd IfElseSet objAttr = objDoc.
createAttribute(attr)objChild.setAttribute attr, valEnd IfobjDoc.documentElement.appendChild(objChild)objDoc.Save strFileSet objChild = NothingEnd Function
'Create a child node under the specified XPath NodePublic Function createChildNode(strXPath, strNode)Dim objParent, objChildFor Each objParent In objDoc.
documentElement.selectNodes(strXPath)Set objChild = objDoc.createNode(1, strNode, '')objParent.appendChild(objChild)NextobjDoc.Save strFileSet 
objParent = NothingSet objChild = NothingEnd Function
'Create a child node(s) under the specified XPath Node with attributesPublic Function createChildNodeWAttr(strXPath, strNode, attr, val)Dim objParent, objChild, 
objAttrFor Each objParent In objDoc.documentElement.selectNodes(strXPath)Set objChild = objDoc.createNode(1, strNode, '')If IsArray(attr) And IsArray(val) 
ThenIf UBound(attr)-LBound(attr) <> UBound(val)-LBound(val) ThenExit FunctionElseDim iFor i = LBound(attr) To UBound(attr)Set objAttr = objDoc.
createAttribute(attr(i))objChild.SetAttribute attr(i), val(i)NextEnd IfElseSet objAttr = objDoc.createAttribute(attr)objChild.setAttribute attr, 
valEnd IfobjParent.appendChild(objChild)NextobjDoc.Save strFileSet objParent = NothingSet objChild = NothingEnd Function
'Delete the node specified by the XPathPublic Function deleteNode(strXPath)Dim objOldFor Each objOld In objDoc.documentElement.selectNodes(strXPath)objDoc.
documentElement.removeChild objOldNextobjDoc.Save strFileSet objOld = NothingEnd FunctionEnd Class%>

以上是“vbs类自带xml文件有哪些”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联成都网站设计公司行业资讯频道!

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

分享名称:vbs类自带xml文件有哪些-创新互联
转载注明:https://www.cdcxhl.com/article16/cogogg.html

成都网站建设公司_创新互联,为您提供响应式网站软件开发外贸网站建设网站策划搜索引擎优化网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

搜索引擎优化