Sub 提取5列故障码()
Dim xDoc As New DOMDocument60
Set xDoc = New MSXML2.DOMDocument60
mypath = ThisWorkbook.Path & "\"
MyFile = mypath & Dir(mypath & "*.dita")
xDoc.async = True
xDoc.validateOnParse = False
[a1:e65536].Clear
Do While MyFile <> mypath
xDoc.Load (MyFile)
'获取row标签节点
For Each x In xDoc.DocumentElement.getElementsByTagName("row")
i = i + 1
Do While (i = 1)
If x.ChildNodes.length = 5 Then
For j = 1 To x.ChildNodes.length
Cells(i, j) = x.ChildNodes.Item(j - 1).Text
Next
End If
Exit Do
Loop
Do While (i <> 1)
If x.ChildNodes.length = 1 Then
For j = 1 To x.ChildNodes.length
Cells(i, 4) = x.ChildNodes.Item(j - 1).Text
Next
End If
If x.ChildNodes.length = 2 Then
For j = 1 To x.ChildNodes.length
Cells(i, 4) = x.ChildNodes.Item(j - 1).Text
Next
End If
If x.ChildNodes.length = 5 Then
For j = 1 To x.ChildNodes.length
Cells(i, j) = x.ChildNodes.Item(j - 1).Text
XML0 = x.ChildNodes.Item(j - 1).XML
If j = 5 Then Cells(i, j) = Mid(XML0, InStr(XML0, "href=""") + 6, 14)
Next
End If
Exit Do
Loop
Next
MyFile = mypath & Dir
Loop
End Sub
xml中table标签内容样式:
提取到表格中的内容样式: