asp读取xml实例代码
程序员文章站
2022-06-24 16:12:02
language.xml 复制代码 代码如下:
language.xml
<?xml version="1.0" encoding="gb2312"?>
<languageroot>
<!--简体中文-->
<language>
<languagename>简体中文</languagename>
<languagevalue>simpilifiedchinese</languagevalue>
<languageimages>images</languageimages>
<languagefile></languagefile>
</language>
<!--繁體中文-->
<language1>
<languagename>繁體中文</languagename>
<languagevalue>traditionalchinese</languagevalue>
<languageimages>imagesbig5</languageimages>
<languagefile>ddd</languagefile>
</language1>
</languageroot>
sl.asp
<%
set objxml2 = server.createobject("msxml2.domdocument")
objxml2.async = false
loadresult = objxml2.load(server.mappath("language.xml"))
if not loadresult then
response.write "装载xml文件错误"
response.end
end if
set objnodes = objxml2.getelementsbytagname("languageroot/language")
for i = 0 to objnodes.length - 1
response.write trim(objnodes(i).selectsinglenode("languagename").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languagevalue").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languageimages").text)&"<br>"
next
set objnodes = nothing
set objnodes = objxml2.getelementsbytagname("languageroot/language1")
for i = 0 to objnodes.length - 1
response.write trim(objnodes(i).selectsinglenode("languagename").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languagevalue").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languageimages").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languagefile").text)&"<br>"
next
set objnodes = nothing
set objxml = nothing
%>
以上代码,经编辑测试通过。
复制代码 代码如下:
<?xml version="1.0" encoding="gb2312"?>
<languageroot>
<!--简体中文-->
<language>
<languagename>简体中文</languagename>
<languagevalue>simpilifiedchinese</languagevalue>
<languageimages>images</languageimages>
<languagefile></languagefile>
</language>
<!--繁體中文-->
<language1>
<languagename>繁體中文</languagename>
<languagevalue>traditionalchinese</languagevalue>
<languageimages>imagesbig5</languageimages>
<languagefile>ddd</languagefile>
</language1>
</languageroot>
sl.asp
复制代码 代码如下:
<%
set objxml2 = server.createobject("msxml2.domdocument")
objxml2.async = false
loadresult = objxml2.load(server.mappath("language.xml"))
if not loadresult then
response.write "装载xml文件错误"
response.end
end if
set objnodes = objxml2.getelementsbytagname("languageroot/language")
for i = 0 to objnodes.length - 1
response.write trim(objnodes(i).selectsinglenode("languagename").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languagevalue").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languageimages").text)&"<br>"
next
set objnodes = nothing
set objnodes = objxml2.getelementsbytagname("languageroot/language1")
for i = 0 to objnodes.length - 1
response.write trim(objnodes(i).selectsinglenode("languagename").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languagevalue").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languageimages").text)&"<br>"
response.write trim(objnodes(i).selectsinglenode("languagefile").text)&"<br>"
next
set objnodes = nothing
set objxml = nothing
%>
以上代码,经编辑测试通过。
上一篇: asp最简单的生成验证码代码
下一篇: 利用DOS命令来对抗U盘病毒保护U盘数据