vbs类生成xml文件

来源:互联网 发布:淘宝手机端添加视频 编辑:程序博客网 时间:2024/04/28 05:16
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

有两文件:
objxml.asp:测试文件
clsxml.asp:vbs文件
代码:
objxml.asp

<%@ Language=vbscript %>
<% Option Explicit %>
<!--#INCLUDE FILE="clsxml.asp"-->
<%
Dim objxml, strPath, str
Set 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 Node
objxml.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 updated
objxml.updateField "Jobs[@Size=24]", "24's"

'Notice that only two nodes have the specified XPath, hence
'only two new child nodes will be added
objxml.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>")
Next
Set objxml = Nothing

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>