Answers for "vba parse xml file"


vba parse xml file

' Basic parsing of xml file
' Add Reference "Microsoft XML, v6.0" to your project
Sub XMLParse()
    Dim oXml As New MSXML2.DOMDocument60
    Dim lNodes  As IXMLDOMNodeList, xNode As IXMLDOMNode
    oXml.Load ("C:\temp\misc.xml")
    With oXml.DocumentElement
        Set lNodes = .SelectNodes("food")       'or try :
        Set lNodes = .SelectNodes("food/name")
    End With
    For Each xNode In lNodes
        With xNode
            Debug.Print .ParentNode.nodeName & "/" & .nodeName & " : " & .Text
        End With
    Next xNode
End Sub

' XML sample (misc.xml):
<?xml version="1.0" encoding="UTF-8"?>
        <name>Belgian Waffles</name>
        <name>Strawberry Belgian Waffles</name>
Posted by: Guest on January-21-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language