佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > Asp操作Xml的精煉類,含示例代碼

Asp操作Xml的精煉類,含示例代碼

熱門標(biāo)簽:團(tuán)購(gòu)網(wǎng)站 電子圍欄 銀行業(yè)務(wù) 服務(wù)器配置 Mysql連接數(shù)設(shè)置 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 阿里云 Linux服務(wù)器
以下保存成 App.xml , 與asp文件放在相同目錄下!
復(fù)制代碼 代碼如下:

?xml version="1.0" encoding="utf-8"?>
Root>
About>
Version>1.0 Beta/Version>
LatestVersion>1.0 Beta/LatestVersion>
Author>Author/Author>
PubDate>2010/02/20/PubDate>
/About>
Config>
Installed>False/Installed>
BakPath>_Data/BakPath>
/Config>
/Root>

以下為Asp類及使用方法,請(qǐng)保存成test.asp, 測(cè)試運(yùn)行
復(fù)制代碼 代碼如下:

%
Class AppConfig
Dim XmlDom
Private Sub Class_Initialize()
Set XmlDom = Server.createobject("microsoft.xmldom")
XmlDom.load(Server.mappath("App.xml"))
End Sub
Private Sub Class_Terminate()
Set XmlDom = Nothing
End Sub
Function GetD(key)
GetD =XmlDom.getElementsByTagName(key)(0).text
End Function
Function SetD(key,val)
XmlDom.getElementsByTagName(key)(0).text = val
XmlDom.save(Server.mappath("App.xml"))
End Function
Function AddD(node,key,val)
Set newnode=XmlDom.getElementsByTagName(node)(0).appendchild(XmlDom.createelement(key))
newnode.text = val
Set newnode=Nothing
XmlDom.save(Server.mappath("App.xml"))
End Function
Function DelD(key)
On Error Resume Next
XmlDom.getElementsByTagName(key)(0).parentNode.removechild(XmlDom.getElementsByTagName(key)(0))
XmlDom.save(Server.mappath("App.xml"))
End Function
End Class
Set Config = new AppConfig
wn Config.GetD("Version")
wn Config.GetD("LatestVersion")
wn Config.GetD("Author")
wn Config.GetD("PubDate")
wn Config.GetD("Installed")
wn Config.GetD("BakPath")
' 去掉相應(yīng)的注釋符,即可看到 [添加 / 編輯 / 刪除] 節(jié)點(diǎn)的效果
'Call Config.AddD("Config","test","test") ' 添加節(jié)點(diǎn)
'Call Config.SetD("test","test2") ' 編輯節(jié)點(diǎn)
'Call Config.DelD("test") ' 刪除節(jié)點(diǎn)
Sub wn(str)
Response.Write(str)"br />"vbcrlf
End Sub
%>

不是很通吃,但某些情況下的運(yùn)用足夠了, 基本可以實(shí)現(xiàn)添加/刪除/修改節(jié)點(diǎn)
您可能感興趣的文章:
  • asp下將數(shù)據(jù)庫(kù)中的信息存儲(chǔ)至XML文件中
  • asp access數(shù)據(jù)庫(kù)并生成XML文件范例
  • Javascript+XMLHttpRequest+asp.net無(wú)刷新讀取數(shù)據(jù)庫(kù)數(shù)據(jù)
  • ASP XML操作類代碼
  • ASP讀取XML實(shí)例 優(yōu)酷專輯采集程序 雷鋒版
  • ASP XMLDom在服務(wù)器端操作XML文件的主要方法和實(shí)現(xiàn)
  • ASP.NET+XML打造網(wǎng)絡(luò)硬盤原理分析
  • asp xmlhttp下載一句話
  • asp.net TreeView與XML三步生成列表樹
  • Asp 解析 XML并分頁(yè)顯示源碼
  • ASP.NET中XML轉(zhuǎn)JSON的方法實(shí)例
  • ASP.net處理XML數(shù)據(jù)實(shí)例淺析
  • ASP.NET XmlDocument類詳解
  • asp.net中XML如何做增刪改查操作
  • asp控制xml數(shù)據(jù)庫(kù)的經(jīng)典代碼

標(biāo)簽:萍鄉(xiāng) 江蘇 大理 衡水 蚌埠 棗莊 廣元 衢州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Asp操作Xml的精煉類,含示例代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    丽水市| 宜兰县| 沂南县| 贵南县| 云龙县| 北碚区| 闻喜县| 巴马| 湖口县| 曲阜市| 岳普湖县| 万山特区| 德令哈市| 禹州市| 舟曲县| 都匀市| 陈巴尔虎旗| 开原市| 桃源县| 葫芦岛市| 吉木乃县| 宁晋县| 昌江| 马边| 广平县| 海伦市| 邯郸县| 苍梧县| 大姚县| 金塔县| 台北县| 嵩明县| 汝南县| 锦州市| 新疆| 梧州市| 拜泉县| 青州市| 平远县| 洪洞县| 厦门市|