看板 Visual_Basic 關於我們 聯絡資訊
以下是我寫的 當我讀取資料量只有40筆的資料,能夠很快就讀完寫出到txt上 不過我讀取有50000筆的資料量時,它執行的非常非常慢,兩天才寫到txt上30筆資料. 我主要的目的是要把xml的資料讀取並寫到txt上,好作為我以後的抓值. Private Sub Command1_Click() ' Load an xml document into a DOM instance. Dim oXMLDom As New DOMDocument30 oXMLDom.async = False oXMLDom.validateOnParse = False oXMLDom.resolveExternals = False oXMLDom.preserveWhiteSpace = True If oXMLDom.Load(App.Path + "\Test_Sheet_Conditions1000.xml") = False Then MsgBox "Failed to load xml data from file." Exit Sub End If GoTo MoreNodes1 MoreNodes1: ' Query a node-set. Dim oNodes As IXMLDOMNodeList Dim temp(1000, 4) As String f1 = App.Path + "\data1.txt" Open f1 For Output As #1 For q = 0 To 999 Set oNodes = oXMLDom.selectNodes("//qmd_item[" + Trim(q) + "]/*") For i = 1 To oNodes.length Set oNode = oNodes.nextNode If Not (oNode Is Nothing) Then sName = oNode.nodeName sdata = oNode.Text temp(q + 1, i ) = sdata Print #1, temp(q + 1, i ) End If Next i Next q Close #1 MsgBox "執行完成" End Sub -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.132.196.119