xml文件读取,结构复杂的xml```求教大神
<?xml version="1.0" encoding="utf-8"?><LidcReadMessage uid="1.3.6.1.4.1.14519.5.2.1.6279.6001.1307390687803.0" xmlns="http://www.nih.gov" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nih.gov http://troll.rad.med.umich.edu/lidc/LidcReadMessage.xsd">
<ResponseHeader>
<Version>1.8.1</Version>
<MessageId>-421198203</MessageId>
<DateRequest>2007-11-01</DateRequest>
<TimeRequest>12:30:44</TimeRequest>
<RequestingSite>removed</RequestingSite>
<ServicingSite>removed</ServicingSite>
<TaskDescription>Second unblinded read</TaskDescription>
<CtImageFile>removed</CtImageFile>
<SeriesInstanceUid>1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192</SeriesInstanceUid>
<DateService>2008-08-18</DateService>
<TimeService>02:05:51</TimeService>
<ResponseDescription>1 - Reading complete</ResponseDescription>
<StudyInstanceUID>1.3.6.1.4.1.14519.5.2.1.6279.6001.298806137288633453246975630178</StudyInstanceUID>
</ResponseHeader>
<readingSession>
<annotationVersion>3.12</annotationVersion>
<servicingRadiologistID>540461523</servicingRadiologistID>
<unblindedReadNodule>
<noduleID>Nodule 003</noduleID>
<roi>
<imageZposition>-175.000000 </imageZposition>
<imageSOP_UID>1.3.6.1.4.1.14519.5.2.1.6279.6001.315606855383999143703852453142</imageSOP_UID>
<inclusion>TRUE</inclusion>
<edgeMap>
<xCoord>403</xCoord>
<yCoord>272</yCoord>
</edgeMap>
</roi>
</unblindedReadNodule>
<unblindedReadNodule>
<noduleID>Nodule 004</noduleID>
<roi>
<imageZposition>-175.000000 </imageZposition>
<imageSOP_UID>1.3.6.1.4.1.14519.5.2.1.6279.6001.315606855383999143703852453142</imageSOP_UID>
<inclusion>TRUE</inclusion>
<edgeMap>
<xCoord>392</xCoord>
<yCoord>317</yCoord>
</edgeMap>
</roi>
</unblindedReadNodule>
<nonNodule>
<nonNoduleID>_Non-nodule 001</nonNoduleID>
<imageZposition>-185.000000 </imageZposition>
<imageSOP_UID>1.3.6.1.4.1.14519.5.2.1.6279.6001.265752406785564034990206112632</imageSOP_UID>
<locus>
<xCoord>396</xCoord>
<yCoord>216</yCoord>
</locus>
</nonNodule>
<nonNodule>
<nonNoduleID>_Non-nodule 002</nonNoduleID>
<imageZposition>-242.500000 </imageZposition>
<imageSOP_UID>1.3.6.1.4.1.14519.5.2.1.6279.6001.588464900616851045070333788793</imageSOP_UID>
<locus>
<xCoord>200</xCoord>
<yCoord>342</yCoord>
</locus>
</nonNodule>
<nonNodule>
<nonNoduleID>_Non-nodule 003</nonNoduleID>
<imageZposition>-175.000000 </imageZposition>
<imageSOP_UID>1.3.6.1.4.1.14519.5.2.1.6279.6001.315606855383999143703852453142</imageSOP_UID>
<locus>
<xCoord>109</xCoord>
<yCoord>291</yCoord>
</locus>
</nonNodule>
<nonNodule>
<nonNoduleID>_Non-nodule 004</nonNoduleID>
<imageZposition>-165.000000 </imageZposition>
<imageSOP_UID>1.3.6.1.4.1.14519.5.2.1.6279.6001.980992723094835143194725792701</imageSOP_UID>
<locus>
<xCoord>212</xCoord>
<yCoord>157</yCoord>
</locus>
</nonNodule>
</readingSession>
</LidcReadMessage>
以上为xml内容,希望利用vb读取xml内容,存入access数据库,我刚学习xml对这么复杂的真心搞不定啊··· XML access VB --------------------编程问答-------------------- 再复杂的XML,把所有的节点及子节点找到,也就好办了。 --------------------编程问答-------------------- http://http://support.microsoft.com/kb/263247 --------------------编程问答-------------------- --------------------编程问答-------------------- access数据库的格式是什么样子的? --------------------编程问答-------------------- 直接在界面上现实就行了 --------------------编程问答--------------------
--------------------编程问答-------------------- 再加一个循环,并且同时读出标签名称:
Sub 读取结构复杂的xml()
On Error Resume Next
URL = "C:\Documents and Settings\Administrator\桌面\读取结构复杂的xml.xml" 'XML文件地址
With CreateObject("Microsoft.XMLDOM")
.async = False
.Load (URL)
Set s1 = .DocumentElement.ChildNodes
For i = 0 To s1.Length - 1
Set s2 = s1(i).ChildNodes
For j = 0 To s2.Length - 1
Debug.Print s2(j).Text
Next j
Next i
End With
End Sub
Sub 读取结构复杂的xml()
On Error Resume Next
URL = "C:\Documents and Settings\Administrator\桌面\读取结构复杂的xml.xml" 'XML文件地址
With CreateObject("Microsoft.XMLDOM")
.async = False
.Load (URL)
Set s1 = .DocumentElement.ChildNodes
For i = 0 To s1.Length - 1
Set s2 = s1(i).ChildNodes
For j = 0 To s2.Length - 1
If s2(j).ChildNodes.Length > 1 Then
Set s3 = s2(j).ChildNodes
For k = 0 To s3.Length - 1
Debug.Print s3(k).Text, s3(k).Nodename
Next k
Debug.Print "++++++++++++++"
Else
Debug.Print s2(j).Text, s2(j).Nodename
End If
Next j
Debug.Print "***********"
Next i
End With
End Sub
补充:VB , 基础类