Private Sub cmdLoad_Click() Dim oDoc As DOMDocument60 Dim fSuccess As Boolean Dim oRoot As IXMLDOMNode Dim oCountry As IXMLDOMNode Dim oAttributes As IXMLDOMNamedNodeMap Dim oCountryName As IXMLDOMNode Dim oChildren As IXMLDOMNodeList Dim oChild As IXMLDOMNode Dim intI As Integer Dim XMLString As String On Error GoTo HandleErr Set oDoc = New DOMDocument60 oDoc.async = False oDoc.validateOnParse = False fSuccess = oDoc.Load("c:\traffic1.xml") ' If anything went wrong, quit now. If Not fSuccess Then GoTo ExitHere End If ' Get the root of the XML tree. Set oRoot = oDoc.documentElement ' Go through all children of the root. For Each oCountry In oRoot.childNodes ' Collect the attributes for this country/region. Set oAttributes = oCountry.Attributes ' Extract the country/region name and Set oCountryName = oAttributes.getNamedItem("CountryName") Debug.Print oCountryName.Text ' Go through all the children of the country/region node. Set oChildren = oCountry.childNodes For Each oChild In oChildren If oChild.nodeName = "TotalVisits" Then Debug.Print oChild.nodeTypedValue End If If oChild.nodeName = "LatestVisit" Then Debug.Print oChild.nodeTypedValue End If Next oChild Next oCountry ExitHere: Exit Sub HandleErr: MsgBox "Error " & Err.Number & ": " & Err.Description Resume ExitHere Resume End Sub
Experts 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