ransomedbyfire
Board Regular
- Joined
- Mar 9, 2011
- Messages
- 121
I am trying to get data from an XML file into a spreadsheet using VBA. I have looked up how to do this. And I get the main gist, but it seems that the example I have been looking at is too simple to answer my questions.
I am dealing with an XML file that appears to have the structure:
Document
and so on
I've read how to use VBA to get data from a child node of the root using code like this:
<code>
Set root = doc.DocumentElement
For Each element In root.ChildNodes
Set attributes = group.attributes
Set langcode = attributes.getNamedItem("langcode")
ActiveSheet.Cells(int1, 1).Value = langcode.Text
Set children = group.ChildNodes
For Each child In children
If child.nodeName = "GroupID" Then
ActiveSheet.Cells(int1, 2) = child.nodeTypedValue
End If
</code>
But how do you get data from a child of a child of a child of a child of the root? (I am particularly interested in securitysymbol and securitycodedescription.
I am dealing with an XML file that appears to have the structure:
Document
AsOfDate
DataSetName
Models
DataSetName
Models
Model
#id
CategoriesOrSymbols
CategoriesOrSymbols
SecuritySymbol
CodeDescription
ModelSecurities
ModelSecurities
SectorCodeDescription
I've read how to use VBA to get data from a child node of the root using code like this:
<code>
Set root = doc.DocumentElement
For Each element In root.ChildNodes
Set attributes = group.attributes
Set langcode = attributes.getNamedItem("langcode")
ActiveSheet.Cells(int1, 1).Value = langcode.Text
Set children = group.ChildNodes
For Each child In children
If child.nodeName = "GroupID" Then
ActiveSheet.Cells(int1, 2) = child.nodeTypedValue
End If
</code>
But how do you get data from a child of a child of a child of a child of the root? (I am particularly interested in securitysymbol and securitycodedescription.