trans_xml.asp

来自「武汉软件园人力资源管理系统完整源代码,希望大家能够多多交流.」· ASP 代码 · 共 50 行

ASP
50
字号
<!--#include file="../Include/conn.asp"-->
<%
dim res
set res=server.CreateObject("ADODB.recordset")
res.Open "select (high_dept+'/'+dept_meanid) as 'id',dept_name from dept where dept_state='启用'",conn,3,1

dim xmldoc
set xmldoc=server.CreateObject("Microsoft.XMLDOM")                     '创建DOM对象            
if(xmldoc.childnodes.length = 0) then
    
	set Depts=xmldoc.CreateNode("element","Depts","")                     '创建根结点
	xmldoc.appendchild(Depts)                                             '添加根结点
	
	Set department = xmldoc.CreateNode("element","department","")        '创建第一个子结点
	Depts.appendchild(department)                                        '添加子结点 
	
	Set Id=xmldoc.CreateNode("element","Id","") 
	Id.text="TB/DP0000"     
    department.appendchild(Id)                                       

	Set name=xmldoc.CreateNode("element","Name","")
	name.text="TB"
    department.appendchild(name)
	
    
	Do While Not res.eof=True                                                '创建数据子结点
	    Set department = xmldoc.CreateNode("element","department","")        '创建子结点
		Depts.appendchild(department)                                        '添加子结点 
		
		Set Id=xmldoc.CreateNode("element","Id","")         
		Id.text=res("id")                                               '加入子点结中数据
		department.appendchild(Id)                                      '添加子结点

		Set name=xmldoc.CreateNode("element","Name","")
		name.text=res("dept_name")
		department.appendchild(name)

        res.movenext
	Loop
end If
res.close
conn.close
Set res=Nothing
Set conn=Nothing
    
xmldoc.save server.mappath("Dept_struct.xml")

Response.Redirect "Struct_show.asp"
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?