最近开始需要用的XML,希望得到一些信息,谢谢大家!www.3EXWare.com
解决方案 »
- 关于CommonDialog
- On Error Goto 难道有次数限制?
- 请教一个sub main的问题
- 各位达人帮帮忙,如何来设置控件vaspread的控件的每一列的列名?
- 请教在VB中如何搜索指定的文件呵指定类型的文件?
- 使用vb的treeview控件,目录距离太宽,哪里可以设置得紧凑一点
- 怎么在数据库中存取blob内容
- 关于VB浏览器问题,找遍CSDN和BAIDU还是没有解决!
- 怎样在自定义控件中实现Datasource属性
- 如何实现文件夹共享
- 请问如何 在我刚导出的 excel abc.xls.sheet1 中 首先 第一行加入 一个标题 高度为20 之后每20条记录自动加入 这样的标题
- 关于逻辑字体的问题
Private oNode As IXMLDOMNode定义一个数据集合
Set oElement = oDoc.selectSingleNode("root/Items")
Dim cc As Integer
cc = 0
For Each oNode In oElement.childNodes
rsSourse.AddNew
For i = 1 To 13
rsSourse("col" & i) = oNode.Attributes.getNamedItem("value" & i).Text
Next
rsSourse.Update
cc = cc + 1
Next直接去读进oDoc.selectSingleNode
Set oDoc = New DOMDocument
oDoc.async = False
oDoc.Load sXML '暂时注释 Set oElement = oDoc.documentElement
oElement.selectNodes ("root") prtBill.Caption = oDoc.selectSingleNode("root/Title/@value").Text
With prtBill.Sections(2).Controls
.Item("lblTitle").Caption = oDoc.selectSingleNode("root/Title/@value").Text去MSDN上找些参考资料,一时间是说不清楚的
http://search.csdn.net/Expert/topic/2191/2191642.xml?temp=.2992975
自己做读写的函数也很方便的,无非是分析字符串~
Public Sub LoadDocument()
Dim xDoc As MSXML.DOMDocument
Set xDoc = New MSXML.DOMDocument
xDoc.validateOnParse = False
If xDoc.Load(App.Path & "\" & Employee.xml) Then
' The document loaded successfully.
' Now do something intersting.
DisplayNode xDoc.childNodes, 0
Else
' The document failed to load.
' See the previous listing for error information.
End If
End Sub
Public Sub DisplayNode(ByRef Nodes As MSXML.IXMLDOMNodeList, ByVal Indent As Integer)
Dim xNode As MSXML.IXMLDOMNode
Indent = Indent + 2
For Each xNode In Nodes
If xNode.nodeType = NODE_TEXT Then
Debug.Print Space$(Indent) & xNode.parentNode.nodeName & ":" & xNode.nodeValue
End If
If xNode.hasChildNodes Then
DisplayNode xNode.childNodes, Indent
End If
Next xNode
End Sub
用VB一行行分析速度很慢呀而且容易疏漏
我会尽快结帖的。
dim thexmldom
Private Sub Class_Initialize
set thexmldom=createobject("Microsoft.XMLDOM")
end subpublic function openxml(thefile)
thexmldom.async=false
thexmldom.load thefile
end functionpublic function itemlen(tag)
set itemthing=thexmldom.getElementsByTagName(tag)
itemlen=itemthing.length
end functionpublic 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 functionpublic 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 functionfunction 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 functionfunction 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 functionPrivate Sub Class_Terminate
set thexmldom=nothing
End Subend class
有兴趣单聊:QQ 419451334
////////////////////////////////////////
我是一只菜菜菜菜鸟,想要飞啊飞啊飞,却时常都会往下掉。到现在 毫无所成,却碰了好多的包包,我的技术算不算 太糟?0.1985年出生于医院。1.无不良嗜好。
2.面向金钱编程。
3.欺负你,就是欺负你!
我会尽快结帖的。
你提供的以下地址里的例子特别好,但里面的XML文档(' flight.xml为描述航班信息的XML文档 )在哪儿找得到?谢谢
http://search.csdn.net/Expert/topic/1976/1976931.xml?temp=.2910578