就这么简单 ^_^
<%
Dim sFile,objXML,rootElement,getNodeTxt
sFile=Server.MapPath("x1.xml")
Set objXML=Server.CreateObject("Microsoft.XMLDOM")
objXML.async=False
objXML.load(sFile)
Set rootElement=objXML.documentElement
If IsObject(rootElement)=False Then
Response.Write "can not load root!"
Response.End
End If
getNodeTxt=rootElement.childNodes(0).childNodes(1).text
'rootElement=><MadeImage>
'childNodes(0)=><Resonse>
'childNodes(1)=><imageurl>
'text=>images/102369844.gif
Response.Write getNodeTxt
Response.End
Set objXML=Nothing
%>
aspXML.asp
============================================================================
<%
Class ASPXML
Private objDom,objnodes,objTable,Xml_Array,XMLnodes,ID,brstr,NewXMLnode,NewXMLcooky
Public Path,Data,Xml_Eof,Xml_Bof,Xml_Item,Xml_Count
'打开文档
Public Sub open()
set objDom=server.CreateObject("Microsoft.XMLDOM")
objDom.load Path
set objnodes=objdom.documentElement.SelectSingleNode("//"+Data+"").ChildNodes
set XMLnodes=objdom.documentElement.SelectSingleNode("//"+Data+"")
end sub
'选择表
Public Function SelectTable(Table)
objTable=Table
Xml_Count=-1
Xml_Eof=false
Xml_Bof=false
'Xml_Item=2
if Xml_Item="" then
Xml_Item=0
end if
GETCount()
ChkCount()
end Function
'下移一行
Public Sub MoveNext()
Xml_Item=Xml_Item+1
ChkCount()
end sub
'上移一行
Public Sub MoveLast()
Xml_Item=Xml_Item-1
ChkCount()
end sub
'读出值
Public Function Read(key)
Read=objnodes(int(Xml_Array(Xml_Item))).selectSingleNode(key).text
end Function
'写入
Public Function Write(key,viold)
objnodes(int(Xml_Array(Xml_Item))).selectSingleNode(key).text=viold
end Function
'查询字段
Public Function SelectItem(key,viold)
Xml_AllTableWords=""
for i=0 to Xml_Count
xml_viold=objnodes(int(Xml_Array(i))).selectSingleNode(key).text
if xml_viold=viold then
Xml_AllTableWords=Xml_AllTableWords+"|"+Xml_Array(i)
end if
next
StrPtr = instr(Xml_AllTableWords, "|")
Xml_AllTableWords = mid(Xml_AllTableWords, StrPtr+1)
Xml_Array=split(Xml_AllTableWords , "|")
Xml_Count=UBound(Xml_Array)
ChkCount()
end Function
'新加记录
Public sub addnew()
NewXMLnode=""
if XMLnodes.hasChildNodes then
ID = XMLnodes.lastchild.firstchild.text+1
else
'如是没有字子节点则是第一次留言ID号设为1
ID=1
end if
brstr=chr(13)&chr(10)&chr(9)
NewXMLcooky=brstr&"<"&objTable&">"&brstr &"<ID>"&ID&"</ID>"&brstr
end sub
'添加数值
Public Function add(key,viold)
NewXMLcooky=NewXMLcooky&"<"&key&">"&viold&"</"&key&">"&brstr
NewXMLnode=NewXMLcooky&"</"&objTable&">"&chr(13)
end Function
'删除记录
Public Function delect(key,viold)
for i=0 to Xml_Count
if ISkeyOk(key,viold) then
XMLnodes.removechild(objDom.selectsinglenode("//"&objTable&"["&key&"='"&viold&"']"))
end if
next
objDom.save(Path)
end Function
'删除表
Public Function delectTable()
for i=0 to Xml_Count
XMLnodes.removechild(objDom.selectsinglenode("//"&objTable))
next
objDom.save(Path)
end Function
'更新修改表
Public Sub update()
if NewXMLnode<>"" then
set objXML2=Server.CreateObject("Microsoft.XMLDOM")
'建立一个新XML对像
objXML2.loadXML(NewXMLnode)
'把XML版片段读入内存中
set rootNewNode=objXML2.documentElement
'获得objXML2的根节点
XMLnodes.appendChild(rootNewNode)
end if
objDom.Save(Path)
end sub
'关闭
Public Sub CLOSE()
set objnodes=nothing
set objDom=nothing
' Response.Write(objTable)
end sub
'=====================================================================
Private Function GETCount()
Xml_AllTableWords=""
Xml_AllCount=-1
for each element in objnodes
Xml_AllCount=Xml_AllCount+1
If element.nodename =objTable then
Xml_AllTableWords=Xml_AllTableWords+"|"+cstr(Xml_AllCount)
end if
next
StrPtr = instr(Xml_AllTableWords, "|")
Xml_AllTableWords = mid(Xml_AllTableWords, StrPtr+1)
Xml_Array=split(Xml_AllTableWords , "|")
Xml_Count=UBound(Xml_Array)
end Function
Private Function ChkCount()
if Xml_Count<0 then
Xml_Bof=true
end if
if Xml_Item>Xml_Count then
Xml_Eof=true
end if
end Function
Private Function ISkeyOk(key,viold)
ISkeyOk=false
if not(XMLnodes.hasChildNodes) then
exit Function
end if
for each timent in objnodes
If timent.nodename =objTable then
set pobjnodes=timent.ChildNodes
for each yyment in pobjnodes
if yyment.nodename=key and yyment.text=viold then
ISkeyOk=true
exit Function
end if
next
end if
next
end Function
End Class
%>
=======================================================================