遍历XML文档返回二维数组(ASP)(更新版)

2016-01-29 12:57 30 1 收藏

遍历XML文档返回二维数组(ASP)(更新版),遍历XML文档返回二维数组(ASP)(更新版)

【 tulaoshi.com - ASP.NET 】


<% on error resume next '问题没处理 'xmlfile = "???.xml" Set xml = Server.CreateObject("MSXML.DOMDocument") xml.async = false xml.load(xmlfile)
Public Function PrettyPrint(node,tabLevel)on error resume next If node.nodeName <> vbNullStrin And node.nodeName <> "#text" Then PrettyPrint = PrettyPrint & tabLevel & "[sp2]0[sp2]" + node.nodeName + "[sp1]"
For Each i In node.Attributes pstr = pstr + i.Name + "=" + i.Value + " " Next PrettyPrint = PrettyPrint & tabLevel & "[sp2]2[sp2]" + pstr + "[sp1]" End If If node.hasChildNodes Then For Each childNode In node.childNodes tabLevel=tabLevel+1 PrettyPrint = PrettyPrint + PrettyPrint(childNode, tabLevel) Next Else PrettyPrint = PrettyPrint & tabLevel-1 & "[sp2]1[sp2]" + node.Text + "[sp1]" End IfEnd Function
Public Function ShowXml(s)on error resume next ta = split(s,"[sp1]") k = ubound(ta)-1 'response.write "sta(" &k &",2)

" redim sta(k,2) for i = 0 to k ta2 = split(ta(i),"[sp2]") cs1 = ta2(0) cs2 = ta2(1) cs3 = ta2(2) 'Response.write "sta(" & cs1 & "," & cs2 & ") = " & cs3 & "
" sta(cs1,cs2) = cs3 Next ShowXml = staEnd Function
test = ShowXml(PrettyPrint(xml.documentElement,0))
response.write "" + chr(13) response.write "" response.write "nodeNamenodeValueAttributes" response.write "" + chr(13) for b = 0 to ubound(test) If test(b,0)<>"" then response.write "0 then response.write "bgcolor=#BABBBC" end if response.write ">" response.write "" & test(b,0) & " " response.write "" & test(b,1) & " " response.write "" & test(b,2) & " " response.write "" + chr(13) End if next response.write ""
%>
PrettyPrint函数返回字符串
ShowXml函数处理PrettyPrint的返回值并返回一个二维数组

来源:https://www.tulaoshi.com/n/20160129/1488296.html

延伸阅读
微信二维码支付怎么生成二维码   1)打开微信,点击右下角,选择钱包,再点击左上角。   2)点击,然后点击右上角。   3)输入金额,可以点击进行文字说明,设置好后点击。   4)全部完成后,一个二维码就生成了,只需朋友用微信扫描即可完成转账。
标签: PHP
在oso的工程师的提示下写了一个导航程序。 $host = "localhost"; //主机名 $user = "root"; //mysql用户名 $password = ""; //mysql密码 $database = "doc"; //mysql数据库名 $tables = "mclass"; //表名 $conn=mysql_connect("$host","$user","$password") or die("数据库打开出错"); mysql_select_db("$database")...
《天天酷跑》更新版卡人物坐骑技巧教程 天天酷跑更新版卡人物坐骑技巧教程: 先把数据清了,然后进游戏,一开始播动画时马上断网(手速要快不然有可能失败),然后进去了直接进商场它会一直显示不出东西,这时候在后台把游戏关了然后再进游戏,进去正在加载时又把网断点,然后进商场再把网连上就OK了。 《天天酷跑》1.0.8版钻石任务详情介...
如何制作二维码   1、使用百度输入法,鼠标右键点击百度输入法的图标设置属相,打开设置属性界面。 2、在设置属性界面找到扩展设置选项,选择其中的神码传文并进行安装。 3、启动神码传文的快捷键Ctrl+Shift+R,你也可以在输入界面点击百度图标,勾选神码传文,在输入法界面就有二维码制作图标了,并在其间输入二维码...

经验教程

677

收藏

59
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部