Hey All,
So I have a bunch of XML nodes that look like this:
And I want to loop through all of them and grab the 5 values inside each node and then put them into their corresponding cells in an Excel worksheet. This is my code so far which isn't working:
I want the values from the nodes to be put in the Excel document starting at row 3 (rows 1&2 are headers) and then place the 5 values in collumns 1-5 and then drop a row and put the data for the next node. This currently isn't working because I'm trying to set "trendValue" equal to it's next sibling, which it won't let me do. Does anyone know the proper way to cycle through siblings and grab their attributes?
Thanks for any help,
BitNet
So I have a bunch of XML nodes that look like this:
Code:
<TREND_VALUE
DATE_TIME="20100729101005"
MIN_VALUE="-12"
AVG_VALUE="0"
MAX_VALUE="0"
VALID="TRUE"
/>
<TREND_VALUE
DATE_TIME="20100729102005"
MIN_VALUE="-24"
AVG_VALUE="-12"
MAX_VALUE="0"
VALID="TRUE"
/>
ECT...
Code:
Dim xmlDoc As MSXML2.DOMDocument
Set xmlDoc = New MSXML2.DOMDocument
Dim xl As Object
Set xl = CreateObject("Excel.Application")
Dim trendValue As As MSXML2.IXMLDOMNodeList
Set trendValue = xmlDoc.getElementsByTagName("TRENDS/TREND/TREND_VALUE")
With xl.Workbooks.Add
Worksheets.Add.name = "Trend"
With ActiveSheet.name = "Trend"
For i = 0 To numTrendValuePerTrend
ActiveSheet.Cells(3 + i, 1).Value = trendValue.Item(0).Text
ActiveSheet.Cells(3 + i, 2).Value = trendValue.Item(1).Text
ActiveSheet.Cells(3 + i, 3).Value = trendValue.Item(2).Text
ActiveSheet.Cells(3 + i, 4).Value = trendValue.Item(3).Text
ActiveSheet.Cells(3 + i, 5).Value = trendValue.Item(4).Text
trendValue = trendValue.NextSibling
Next
End With
Thanks for any help,
BitNet