I have been trying to pull some XML data from a website and can't seem to get my loop to cycle through each accrualend date, and the last element should be a total rate as opposed to the single day rate. Below is the code, please be gentle as I am just learning VBA and XML as well. Thanks for any help you may give.
Sub getXMLFRN()
Dim xmldoc As MSXML2.DOMDocument60
Dim xnodesls As MSXML2.IXMLDOMNodeList
Dim xnode As MSXML2.IXMLDOMNode
Dim strcusip As String
Dim straccrualStart As String
Dim straccrualEnd As String
Dim strdailyAccruedInterestPer100 As String
Dim strinterestPaymentPeriodAccruedInterestPer100 As String
Set xmldoc = New MSXML2.DOMDocument60
xmldoc.async = False
xmldoc.Load ("http://ift.tt/1oJmY7I")
For i = 1 To 10
Application.Workbooks("xml test.xlsm").Worksheets("Sheet1").Range("A1:e1").Formula = Array("CUSIP", "Accrual Start", "Accrual End", "Daily Rate", "Total Rate")
strcusip = xmldoc.getElementsByTagName("cusip").Item(0).Text
straccrualStart = xmldoc.getElementsByTagName("accrualStart").Item(0).Text
straccrualEnd = xmldoc.getElementsByTagName("accrualEnd").Item(0).Text
strdailyAccruedInterestPer100 = xmldoc.getElementsByTagName("dailyAccruedInterestPer100").Item(0).Text
strinterestPaymentPeriodAccruedInterestPer100 = xmldoc.getElementsByTagName("interestPaymentPeriodAccruedInterestPer100").Item(0).Text
Sheets(1).Cells(i + 1, 1).Value = strcusip
Sheets(1).Cells(i + 1, 2).Value = straccrualStart
Sheets(1).Cells(i + 1, 3).Value = straccrualEnd
Sheets(1).Cells(i + 1, 4).Value = strdailyAccruedInterestPer100
Sheets(1).Cells(i + 1, 5).Value = interestPaymentPeriodAccruedInterestPer100
Next i
MsgBox ("Done")
End Sub
No comments:
Post a Comment