Block if.
It stinks. I had this problem for days now, and when someone adds a suggestion it does not work. If you can, please hurry, I'm operating on a deadline...
Sub ReadXML()
Dim xml_doc As New DOMDocument
Dim nde1 As IXMLDOMElement
'Dim nde2 As IXMLDOMElement
'Dim nde3 As IXMLDOMElement
xml_doc.Load "C:\Documents and Settings\Censor\Desktop\Censor"
intR = 2
i = 1
With Worksheets("sheet4")
.Cells(intR, 1) = intR - 1
.Cells(intR, 2) = nde1.selectSingleNode("Name").Text
.Cells(intR, 4) = nde1.selectSingleNode("Datatype").Text
.Cells(intR, 3) = nde1.selectSingleNode("Description").Text
End With
intR = intR + 1
If intR = 27 Then Stop
If nde1.hasChildNodes Then
For Each nde2 In nde1.childNodes
'Set nde3 = nde2.parentNode
Next
For Each nde1 In xml_doc.selectNodes("//DatasetColumn")
With Worksheets("sheet4")
.Cells(intR, 1) = intR - 1
.Cells(intR, 2) = nde1.selectSingleNode("Name").Text
.Cells(intR, 4) = nde1.selectSingleNode("Datatype").Text
.Cells(intR, 3) = nde1.selectSingleNode("Description").Text
'.Cells(intR, 1) = nde1.selectSingleNode("Name").Text
'.Cells(intR, 3) = nde1.selectSingleNode("Datatype").Text
'.Cells(intR, 2) = nde3.selectSingleNode("Description").Text
.Cells(intR, 3) = i
.Cells(intR, 4) = nde2.selectSingleNode("MappedLevelName").Text
.Cells(intR, 5) = nde2.selectSingleNode("Description").Text
.Cells(intR, 6) = nde2.selectSingleNode("DefaultDescription").Text
End With
intR = intR + 1
i = i + 1
If intR = 227 And i = 200 Then Stop
Next
End Sub
When I add the end if like a suggestion said, I get
Sub ReadXML()
Dim xml_doc As New DOMDocument
Dim nde1 As IXMLDOMElement
'Dim nde2 As IXMLDOMElement
'Dim nde3 As IXMLDOMElement
xml_doc.Load "C:\Documents and Settings\Censor\Desktop\Censor"
intR = 2
i = 1
With Worksheets("sheet4")
.Cells(intR, 1) = intR - 1
.Cells(intR, 2) = nde1.selectSingleNode("Name").Text
.Cells(intR, 4) = nde1.selectSingleNode("Datatype").Text
.Cells(intR, 3) = nde1.selectSingleNode("Description").Text
End With
intR = intR + 1
If intR = 27 Then Stop
If nde1.hasChildNodes Then
For Each nde2 In nde1.childNodes
'Set nde3 = nde2.parentNode
End if
Next
For Each nde1 In xml_doc.selectNodes("//DatasetColumn")
With Worksheets("sheet4")
.Cells(intR, 1) = intR - 1
.Cells(intR, 2) = nde1.selectSingleNode("Name").Text
.Cells(intR, 4) = nde1.selectSingleNode("Datatype").Text
.Cells(intR, 3) = nde1.selectSingleNode("Description").Text
'.Cells(intR, 1) = nde1.selectSingleNode("Name").Text
'.Cells(intR, 3) = nde1.selectSingleNode("Datatype").Text
'.Cells(intR, 2) = nde3.selectSingleNode("Description").Text
.Cells(intR, 3) = i
.Cells(intR, 4) = nde2.selectSingleNode("MappedLevelName").Text
.Cells(intR, 5) = nde2.selectSingleNode("Description").Text
.Cells(intR, 6) = nde2.selectSingleNode("DefaultDescription").Text
End With
intR = intR + 1
i = i + 1
If intR = 227 And i = 200 Then Stop
Next
End Sub
I get end if without block if problem. Please help, anyone.
BTW, the point of this macro is to display all the info in an xml file into one sheet. Please tell me if I am doing anything else wrong.
Thank you
Bookmarks