asp操作xml
来源:网络收集 责任编辑:栏目编辑 发表时间:2013-07-02 01:41 点击:次
1 最简单的
一个这样的XML文件
<?xml version="1.0" encoding="gb2312"?>
<languageRoot>
<确定 id="one">YES</确定>
<取消>NO</取消>
<提交>Submit</提交>
</languageRoot>
读取
<%
Set objXML = Server.CreateObject("Msxml2.DOMDocument")
objXML.async = False
loadResult = objXML.load(Server.MapPath(strFileName))
if not loadResult then
Response.write "装载XML文件错误"
Response.end
end If
Set objNodes = objXML.getElementsByTagName("languageRoot")
’打印值
Response.Write objNodes(0).selectSingleNode("确定").Text
’打印属性
Response.write objNodes(0).selectSingleNode("确定").getattribute("id")
’==另外一种方式
For i = 0 To objNodes(0).childNodes.length -1
Response.write objNodes(0).childNodes(i).text
next
Set objNodes = Nothing
Set objXML = Nothing
%>
2 一个稍稍复杂一点的
<?xml version="1.0" encoding="gb2312"?>
<languageRoot>
<!--简体中文-->
<language>
<LanguageName>简体中文</LanguageName>
<LanguageValue>SimpilifiedChinese</LanguageValue>
<LanguageImages>images</LanguageImages>
<LanguageFile></LanguageFile>
</language>
<!--繁體中文-->
<language>
<LanguageName>繁體中文</LanguageName>
<LanguageValue>TraditionalChinese</LanguageValue>
<LanguageImages>imagesBig5</LanguageImages>
<LanguageFile></LanguageFile>
</language>
</languageRoot>
读取
Set objXML2 = Server.CreateObject("Msxml2.DOMDocument")
objXML2.async = False
loadResult = objXML2.load(Server.MapPath("asp/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)
Response.write Trim(objNodes(i).selectSingleNode("LanguageValue").Text)
Next
set objNodes = Nothing
Set objXML = Nothing
一个这样的XML文件
<?xml version="1.0" encoding="gb2312"?>
<languageRoot>
<确定 id="one">YES</确定>
<取消>NO</取消>
<提交>Submit</提交>
</languageRoot>
读取
<%
Set objXML = Server.CreateObject("Msxml2.DOMDocument")
objXML.async = False
loadResult = objXML.load(Server.MapPath(strFileName))
if not loadResult then
Response.write "装载XML文件错误"
Response.end
end If
Set objNodes = objXML.getElementsByTagName("languageRoot")
’打印值
Response.Write objNodes(0).selectSingleNode("确定").Text
’打印属性
Response.write objNodes(0).selectSingleNode("确定").getattribute("id")
’==另外一种方式
For i = 0 To objNodes(0).childNodes.length -1
Response.write objNodes(0).childNodes(i).text
next
Set objNodes = Nothing
Set objXML = Nothing
%>
[本文共有 2 页,当前是第 1 页] <<上一页 下一页>>
2 一个稍稍复杂一点的
<?xml version="1.0" encoding="gb2312"?>
<languageRoot>
<!--简体中文-->
<language>
<LanguageName>简体中文</LanguageName>
<LanguageValue>SimpilifiedChinese</LanguageValue>
<LanguageImages>images</LanguageImages>
<LanguageFile></LanguageFile>
</language>
<!--繁體中文-->
<language>
<LanguageName>繁體中文</LanguageName>
<LanguageValue>TraditionalChinese</LanguageValue>
<LanguageImages>imagesBig5</LanguageImages>
<LanguageFile></LanguageFile>
</language>
</languageRoot>
读取
Set objXML2 = Server.CreateObject("Msxml2.DOMDocument")
objXML2.async = False
loadResult = objXML2.load(Server.MapPath("asp/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)
Response.write Trim(objNodes(i).selectSingleNode("LanguageValue").Text)
Next
set objNodes = Nothing
Set objXML = Nothing
[本文共有 2 页,当前是第 2 页] <<上一页 下一页>>
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>