class xmldom
dim thexmldom
Private Sub Class_Initialize
set thexmldom=createobject("Microsoft.XMLDOM")
end sub
public function openxml(thefile)
thexmldom.async=false
thexmldom.load thefile
end function
public function itemlen(tag)
set itemthing=thexmldom.getElementsByTagName(tag)
itemlen=itemthing.length
end function
public function additemblogm(blogtitle,blogcontent,thelink,thefile)
set addroot=thexmldom.createElement("blog")
set root=thexmldom.documentElement
set currnode = root.insertBefore(addroot, root.childNodes(0))
currnode.setAttribute "date",date
currnode.setAttribute "time",time
set blogtitleadd=thexmldom.createElement("blogtitle")
set blogtitled=currnode.appendchild(blogtitleadd)
blogtitled.text=blogtitle
set blogcontentadd=thexmldom.createElement("blogcontent")
set blogcontentd=currnode.appendchild(blogcontentadd)
blogcontentd.text=blogcontent
set bloglinkadd=thexmldom.createElement("link")
set bloglinkd=currnode.appendchild(bloglinkadd)
bloglinkd.text=thelink
set blogcommentadd=thexmldom.createElement("comment")
currnode.appendchild blogcommentadd
thexmldom.save thefile
end function
public function addrecentxml(blogtitle,blogcontent,thelink,thefile,blogshownum)
set root=thexmldom.documentElement
set addroot=thexmldom.createElement("blog")
if root.childNodes.length=0 then
set currnode=root.appendchild(addroot)
else
set currnode = root.insertBefore(addroot, root.childNodes(0))
end if
if root.childNodes.length=blogshownum then
root.removeChild root.lastchild
end if
currnode.setAttribute "date",date
currnode.setAttribute "time",time
set blogtitleadd=thexmldom.createElement("blogtitle")
set blogtitled=currnode.appendchild(blogtitleadd)
blogtitled.text=blogtitle
set blogcontentadd=thexmldom.createElement("blogcontent")
set blogcontentd=currnode.appendchild(blogcontentadd)
blogcontentd.text=blogcontent
set bloglinkadd=thexmldom.createElement("link")
set bloglinkd=currnode.appendchild(bloglinkadd)
bloglinkd.text=thelink
set blogcommentadd=thexmldom.createElement("comment")
currnode.appendchild blogcommentadd
thexmldom.save thefile
end function
function showblogxml()
set blogroot=thexmldom.getElementsByTagName("blog")
bloglen=blogroot.length
for i=0 to bloglen-1
if i=0 then
str="<table><tr><td>"
thedate= blogroot.item(i).getAttribute("date")
str=str & thedate & "</td></tr>"
else
thedate1=blogroot.item(i).getAttribute("date")
if thedate<>thedate1 then
thedate=thedate1
str=str & thedate & "</td></tr>"
end if
end if
str=str & "<tr><td>" & blogroot.item(i).childNodes(0).text & "<br />" & blogroot.item(i).childNodes(1).text & "</td></tr>"
str=str & "<tr><td><a href='" & blogroot.item(i).childNodes(2).text & "'>链接地址</a></td></tr>"
next
if bloglen<>0 then
str=str & "</table>"
end if
showblogxml=str
end function
function ebloginfo(blogtitle,thelink)
set blogroot=thexmldom.getElementsByTagName("blogall")
set currnode=thexmldom.createElement("blog")
bloglen=blogroot.childNodes.length
if bloglen=0 then
set blogcur=blogroot.appendchild(currnode)
else
set blogcur=blogroot.insertBefore(currnode, blogroot.firstchild)
end if
blogcur.setAttribute "link",thelink
blogcur.setAttribute "title",blogtitle
blogcur.setAttribute "date",date
blogcur.setAttribute "time",time
end function
Private Sub Class_Terminate
set thexmldom=nothing
End Sub