Sub IterateThruElements()
Dim xmlDoc As MSXML2.DOMDocument60
Dim xmlNodeList As MSXML2.IXMLDOMNodeList
Dim xmlNode As MSXML2.IXMLDOMNode
Dim myNode As MSXML2.IXMLDOMNode
' Create an instance of the DOMDocument
Set xmlDoc = New MSXML2.DOMDocument60
xmlDoc.async = False
' Load XML information from a file
strPathToXMLFile = Sheets("Settings").Range("B7").Value 'the path to the XML file
xmlDoc.Load (strPathToXMLFile)
' Find out the number of child nodes in the document
Set xmlNodeList = xmlDoc.getElementsByTagName("*")
' Open a new workbook and paste the data
Workbooks.Add
Range("A1:B1").Formula = Array("Element Name", "Text")
For Each xmlNode In xmlNodeList
For Each myNode In xmlNode.ChildNodes
If myNode.NodeType = NODE_TEXT Then
ActiveCell.Offset(0, 0).Formula = xmlNode.nodeName
ActiveCell.Offset(0, 1).Formula = xmlNode.Text
End If
Next myNode
ActiveCell.Offset(1, 0).Select
Next xmlNode
Columns("A:B").AutoFit
End Sub
Excel.JPGExperts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE