天枫庄资源网 Design By www.wosibo.com
<script language="vbscript" runat="server">
'============================================================
'作者:做回自己
'时间:2005-3-15
============================================================
Class XMLClass
Private objXml
Private xmlDoc
Private xmlPath
'//============================================================
'<!--类初始化及注销时的事件-->
Sub Class_initialize
Set objXml = Server.CreateObject("MSXML2.DOMDocument")
objXml.preserveWhiteSpace = true
objXml.async = false
End Sub
Sub Class_Terminate
Set objXml = Nothing
End Sub
'//============================================================
'<!--建立一个新的XML文档-->
Public Function CreateNew(sName)
Set tmpNode = objXml.createElement(sName)
objXml.appendChild(tmpNode)
Set CreateNew = tmpNode
End Function
'<!--从外部读入XML文档-->
Public Function OpenXml(sPath)
OpenXml=False
sPath=Server.MapPath(sPath)
'Response.Write(sPath)
xmlPath = sPath
If objXml.load(sPath) Then
Set xmlDoc = objXml.documentElement
OpenXml=True
End If
End Function
'<!--从外部读入XML字符串-->
Public Sub LoadXml(sStr)
objXml.loadXML(sStr)
Set xmlDoc = objXml.documentElement
End Sub
Public Sub InceptXml(xObj)
Set objXml = xObj
Set xmlDoc = xObj.documentElement
End Sub
'//============================================================
'<!--新增一个节点-->
Public Function AddNode(sNode,rNode)
' sNode STRING 节点名称
' rNode OBJECT 增加节点的上级节点引用
'=============================================================
Dim TmpNode
Set TmpNode = objXml.createElement(sNode)
rNode.appendChild TmpNode
Set AddNode = TmpNode
End Function
'<!--新增一个属性-->
Public Function AddAttribute(sName,sValue,oNode)
' sName STRING 属性名称
' sValue STRING 属性值
' oNode OBJECT 增加属性的对象
'=============================================================
oNode.setAttribute sName,sValue
End Function
'<!--新增节点内容-->
Public Function AddText(FStr,cdBool,oNode)
Dim tmpText
If cdBool Then
Set tmpText = objXml.createCDataSection(FStr)
Else
Set tmpText = objXml.createTextNode(FStr)
End If
oNode.appendChild tmpText
End Function
'========================================================================================================
'<!--取得节点指定属性的值-->
Public Function GetAtt(aName,oNode)
' aName STRING 属性名称
' oNode OBJECT 节点引用
'=============================================================
dim tmpValue
tmpValue = oNode.getAttribute(aName)
GetAtt = tmpValue
End Function
'<!--取得节点名称-->
Public Function GetNodeName(oNode)
' oNode OBJECT 节点引用
GetNodeName = oNode.nodeName
End Function
'<!--取得节点内容-->
Public Function GetNodeText(oNode)
' oNode OBJECT 节点引用
GetNodeText = oNode.childNodes(0).nodeValue
End Function
'<!--取得节点类型-->
Public Function GetNodeType(oNode)
' oNode OBJECT 节点引用
GetNodeType = oNode.nodeValue
End Function
'<!--查找节点名相同的所有节点-->
Public Function FindNodes(sNode)
Dim tmpNodes
Set tmpNodes = objXml.getElementsByTagName(sNode)
Set FindNodes = tmpNodes
End Function
'<!--查打一个相同节点-->
Public Function FindNode(sNode)
Dim TmpNode
Set TmpNode=objXml.selectSingleNode(sNode)
Set FindNode = TmpNode
End Function
'<!--删除一个节点-->
Public Function DelNode(sNode)
Dim TmpNodes,Nodesss
Set TmpNodes=objXml.selectSingleNode(sNode)
Set Nodesss=TmpNodes.parentNode
Nodesss.removeChild(TmpNodes)
End Function
'<!--替换一个节点-->
Public Function ReplaceNode(sNode,sText,cdBool)
'replaceChild
Dim TmpNodes,tmpText
Set TmpNodes=objXml.selectSingleNode(sNode)
'AddText sText,cdBool,TmpNodes
If cdBool Then
Set tmpText = objXml.createCDataSection(sText)
Else
Set tmpText = objXml.createTextNode(sText)
End If
TmpNodes.replaceChild tmpText,TmpNodes.firstChild
End Function
Private Function ProcessingInstruction
'//--创建XML声明
Dim objPi
Set objPi = objXML.createProcessingInstruction("xml", "version="&chr(34)&"1.0"&chr(34)&" encoding="&chr(34)&"gb2312"&chr(34))
'//--把xml生命追加到xml文档
objXML.insertBefore objPi, objXML.childNodes(0)
End Function
'//=============================================================================
'<!--保存XML文档-->
Public Function SaveXML()
'ProcessingInstruction()
objXml.save(xmlPath)
End Function
'<!--另存XML文档-->
Public Function SaveAsXML(sPath)
ProcessingInstruction()
objXml.save(sPath)
End Function
'//==================================================================================
'相关统计
'<!--取得根节点-->
Property Get Root
Set Root = xmlDoc
End Property
'<!--取得根节点下子节点数-->
Property Get Length
Length = xmlDoc.childNodes.length
End Property
'//==================================================================================
'相关测试
Property Get TestNode
TestNode = xmlDoc.childNodes(0).text
End Property
End Class
</script>
'============================================================
'作者:做回自己
'时间:2005-3-15
============================================================
Class XMLClass
Private objXml
Private xmlDoc
Private xmlPath
'//============================================================
'<!--类初始化及注销时的事件-->
Sub Class_initialize
Set objXml = Server.CreateObject("MSXML2.DOMDocument")
objXml.preserveWhiteSpace = true
objXml.async = false
End Sub
Sub Class_Terminate
Set objXml = Nothing
End Sub
'//============================================================
'<!--建立一个新的XML文档-->
Public Function CreateNew(sName)
Set tmpNode = objXml.createElement(sName)
objXml.appendChild(tmpNode)
Set CreateNew = tmpNode
End Function
'<!--从外部读入XML文档-->
Public Function OpenXml(sPath)
OpenXml=False
sPath=Server.MapPath(sPath)
'Response.Write(sPath)
xmlPath = sPath
If objXml.load(sPath) Then
Set xmlDoc = objXml.documentElement
OpenXml=True
End If
End Function
'<!--从外部读入XML字符串-->
Public Sub LoadXml(sStr)
objXml.loadXML(sStr)
Set xmlDoc = objXml.documentElement
End Sub
Public Sub InceptXml(xObj)
Set objXml = xObj
Set xmlDoc = xObj.documentElement
End Sub
'//============================================================
'<!--新增一个节点-->
Public Function AddNode(sNode,rNode)
' sNode STRING 节点名称
' rNode OBJECT 增加节点的上级节点引用
'=============================================================
Dim TmpNode
Set TmpNode = objXml.createElement(sNode)
rNode.appendChild TmpNode
Set AddNode = TmpNode
End Function
'<!--新增一个属性-->
Public Function AddAttribute(sName,sValue,oNode)
' sName STRING 属性名称
' sValue STRING 属性值
' oNode OBJECT 增加属性的对象
'=============================================================
oNode.setAttribute sName,sValue
End Function
'<!--新增节点内容-->
Public Function AddText(FStr,cdBool,oNode)
Dim tmpText
If cdBool Then
Set tmpText = objXml.createCDataSection(FStr)
Else
Set tmpText = objXml.createTextNode(FStr)
End If
oNode.appendChild tmpText
End Function
'========================================================================================================
'<!--取得节点指定属性的值-->
Public Function GetAtt(aName,oNode)
' aName STRING 属性名称
' oNode OBJECT 节点引用
'=============================================================
dim tmpValue
tmpValue = oNode.getAttribute(aName)
GetAtt = tmpValue
End Function
'<!--取得节点名称-->
Public Function GetNodeName(oNode)
' oNode OBJECT 节点引用
GetNodeName = oNode.nodeName
End Function
'<!--取得节点内容-->
Public Function GetNodeText(oNode)
' oNode OBJECT 节点引用
GetNodeText = oNode.childNodes(0).nodeValue
End Function
'<!--取得节点类型-->
Public Function GetNodeType(oNode)
' oNode OBJECT 节点引用
GetNodeType = oNode.nodeValue
End Function
'<!--查找节点名相同的所有节点-->
Public Function FindNodes(sNode)
Dim tmpNodes
Set tmpNodes = objXml.getElementsByTagName(sNode)
Set FindNodes = tmpNodes
End Function
'<!--查打一个相同节点-->
Public Function FindNode(sNode)
Dim TmpNode
Set TmpNode=objXml.selectSingleNode(sNode)
Set FindNode = TmpNode
End Function
'<!--删除一个节点-->
Public Function DelNode(sNode)
Dim TmpNodes,Nodesss
Set TmpNodes=objXml.selectSingleNode(sNode)
Set Nodesss=TmpNodes.parentNode
Nodesss.removeChild(TmpNodes)
End Function
'<!--替换一个节点-->
Public Function ReplaceNode(sNode,sText,cdBool)
'replaceChild
Dim TmpNodes,tmpText
Set TmpNodes=objXml.selectSingleNode(sNode)
'AddText sText,cdBool,TmpNodes
If cdBool Then
Set tmpText = objXml.createCDataSection(sText)
Else
Set tmpText = objXml.createTextNode(sText)
End If
TmpNodes.replaceChild tmpText,TmpNodes.firstChild
End Function
Private Function ProcessingInstruction
'//--创建XML声明
Dim objPi
Set objPi = objXML.createProcessingInstruction("xml", "version="&chr(34)&"1.0"&chr(34)&" encoding="&chr(34)&"gb2312"&chr(34))
'//--把xml生命追加到xml文档
objXML.insertBefore objPi, objXML.childNodes(0)
End Function
'//=============================================================================
'<!--保存XML文档-->
Public Function SaveXML()
'ProcessingInstruction()
objXml.save(xmlPath)
End Function
'<!--另存XML文档-->
Public Function SaveAsXML(sPath)
ProcessingInstruction()
objXml.save(sPath)
End Function
'//==================================================================================
'相关统计
'<!--取得根节点-->
Property Get Root
Set Root = xmlDoc
End Property
'<!--取得根节点下子节点数-->
Property Get Length
Length = xmlDoc.childNodes.length
End Property
'//==================================================================================
'相关测试
Property Get TestNode
TestNode = xmlDoc.childNodes(0).text
End Property
End Class
</script>
标签:
asp,XMLDOM
天枫庄资源网 Design By www.wosibo.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
天枫庄资源网 Design By www.wosibo.com
暂无一个asp版XMLDOM操作类的评论...
更新日志
2024年12月25日
2024年12月25日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]