title: Having trouble with XML phase on VBA Excel
body: <p>I need to parse a XML file having the structure as follows: (I can't show the data as it is confidential)</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;GACDWBulkLoadInterface xsi:schemaLocation=&quot;http://www.example.org/GACDWSchema GACDWSchema.xsd&quot; xmlns=&quot;http://www.example.org/GACDWSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
         &lt;BLConfiguration&gt;
            &lt;BLProperties&gt;
               &lt;BLProperty&gt;
                  &lt;key&gt;isEmpty&lt;/key&gt;
                  &lt;value xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xsi:type=&quot;xsd:boolean&quot;&gt;true&lt;/value&gt;
               &lt;/BLProperty&gt;
            &lt;/BLProperties&gt;
            &lt;version&gt;api-ag-1.1.68-20210315-43&lt;/version&gt;
         &lt;/BLConfiguration&gt;
         &lt;Customer&gt;
            &lt;CustomerID&gt;&lt;/CustomerID&gt;
            &lt;Customer_Name&gt;&lt;/Customer_Name&gt;
            &lt;ISOCountryCode&gt;&lt;/ISOCountryCode&gt;
            &lt;customerType&gt;&lt;/customerType&gt;
            &lt;dataSourceProvider&gt;&lt;/dataSourceProvider&gt;
            &lt;function&gt;&lt;/function&gt;
            &lt;TopLevelCI&gt;
               &lt;Contact Action=&quot;Create&quot;&gt;
                  &lt;Id&gt;4&lt;/Id&gt;
                  &lt;artifactType&gt;&lt;/artifactType&gt;
                  &lt;contactType&gt;&lt;/contactType&gt;
                  &lt;email&gt;&lt;/email&gt;
                  &lt;firstName&gt;&lt;/firstName&gt;
                  &lt;lastName&gt;&lt;/lastName&gt;
                  &lt;userID&gt;&lt;/userID&gt;
                  &lt;ChildCI/&gt;
               &lt;/Contact&gt;
               &lt;PhysicalComputerSystem Action=&quot;Create&quot;&gt;
                  &lt;Id&gt;2&lt;/Id&gt;
                  &lt;artifactType&gt;&lt;/artifactType&gt;
                  &lt;assetLifeCycleState&gt;&lt;/assetLifeCycleState&gt;
                  &lt;category&gt;&lt;/category&gt;
                  &lt;ciLifeCycleState&gt;&lt;/ciLifeCycleState&gt;
                  &lt;custname&gt;&lt;/custname&gt;
                  &lt;description&gt;&lt;/description&gt;
                  &lt;discontinuedDate&gt;&lt;/discontinuedDate&gt;
                  &lt;machineType&gt;&lt;/machineType&gt;
                  &lt;managed&gt;&lt;/managed&gt;
                  &lt;manufacturer&gt;&lt;/manufacturer&gt;
                  &lt;model&gt;&lt;/model&gt;
                  &lt;serialNumber&gt;&lt;/serialNumber&gt;
                  &lt;virtualFlag&gt;&lt;/virtualFlag&gt;
                  &lt;ChildCI&gt;
                     &lt;PhysicalComputerSystemContact Action=&quot;Create&quot;&gt;
                        &lt;contactUID&gt;&lt;/contactUID&gt;
                     &lt;/PhysicalComputerSystemContact&gt;
                     &lt;PhysicalComputerSystemLocation Action=&quot;Create&quot;&gt;
                        &lt;buildingID&gt;&lt;/buildingID&gt;
                        &lt;buildingName&gt;&lt;/buildingName&gt;
                        &lt;city&gt;&lt;/city&gt;
                        &lt;countryName&gt;&lt;/countryName&gt;
                        &lt;isoCountryCode&gt;&lt;/isoCountryCode&gt;
                        &lt;postalCode&gt;&lt;/postalCode&gt;
                        &lt;siteName&gt;&lt;/siteName&gt;
                        &lt;stateProvince&gt;&lt;/stateProvince&gt;
                        &lt;streetAddress&gt;&lt;/streetAddress&gt;
                     &lt;/PhysicalComputerSystemLocation&gt;
                  &lt;/ChildCI&gt;
               &lt;/PhysicalComputerSystem&gt;
               &lt;OperatingSystem Action=&quot;Create&quot;&gt;
                  &lt;Id&gt;1&lt;/Id&gt;
                  &lt;aliasHostname&gt;&lt;/aliasHostname&gt;
                  &lt;artifactType&gt;&lt;/artifactType&gt;
                  &lt;assetLifeCycleState&gt;&lt;/assetLifeCycleState&gt;
                  &lt;backupContr&gt;&lt;/backupContr&gt;
                  &lt;barSaId&gt;&lt;/barSaId&gt;
                  &lt;cacfCustomGroup&gt;&lt;/cacfCustomGroup&gt;
                  &lt;category&gt;&lt;/category&gt;
                  &lt;ciLifeCycleState&gt;&lt;/ciLifeCycleState&gt;
                  &lt;classification&gt;&lt;/classification&gt;
                  &lt;cpuCount&gt;&lt;/cpuCount&gt;
                  &lt;description&gt;&lt;/description&gt;
                  &lt;discontinuedDate&gt;&lt;/discontinuedDate&gt;
                  &lt;fqhn&gt;&lt;/fqhn&gt;
                  &lt;hostsystemID&gt;&lt;/hostsystemID&gt;
                  &lt;hostsystemType&gt;&lt;/hostsystemType&gt;
                  &lt;installationDate&gt;&lt;/installationDate&gt;
                  &lt;ipAddress&gt;&lt;/ipAddress&gt;
                  &lt;majorBusProc&gt;&lt;/majorBusProc&gt;
                  &lt;managed&gt;&lt;/managed&gt;
                  &lt;memory&gt;&lt;/memory&gt;
                  &lt;memoryUnit&gt;&lt;/memoryUnit&gt;
                  &lt;osModLevel&gt;&lt;/osModLevel&gt;
                  &lt;osName&gt;&lt;/osName&gt;
                  &lt;osBuildNumber&gt;&lt;/osBuildNumber&gt;
                  &lt;osProvider&gt;&lt;/osProvider&gt;
                  &lt;osRelease&gt;&lt;/osRelease&gt;
                  &lt;osVersion&gt;&lt;/osVersion&gt;
                  &lt;prodDate&gt;&lt;/prodDate&gt;
                  &lt;purgeDate&gt;&lt;/purgeDate&gt;
                  &lt;purpose&gt;&lt;/purpose&gt;
                  &lt;securityClass&gt;&lt;/securityClass&gt;
                  &lt;serverType&gt;&lt;/serverType&gt;
                  &lt;supportEnddate&gt;&lt;/supportEnddate&gt;
                  &lt;useAliasHostname&gt;&lt;/useAliasHostname&gt;
                  &lt;virtualFlag&gt;&lt;/virtualFlag&gt;
                  &lt;ChildCI&gt;
                     &lt;OperatingSystemContact Action=&quot;Create&quot;&gt;
                        &lt;contactUID&gt;&lt;/contactUID&gt;
                     &lt;/OperatingSystemContact&gt;
                     &lt;OperatingSystemEnvironmentProfile Action=&quot;Create&quot;&gt;
                        &lt;authFlag&gt;&lt;/authFlag&gt;
                        &lt;authExceptDate&gt;&lt;/authExceptDate&gt;
                        &lt;authExceptReasonCode&gt;&lt;/authExceptReasonCode&gt;
                        &lt;authExceptText&gt;&lt;/authExceptText&gt;
                        &lt;disasterRecSys&gt;&lt;/disasterRecSys&gt;
                        &lt;domain&gt;&lt;/domain&gt;
                        &lt;extUsersMax&gt;&lt;/extUsersMax&gt;
                        &lt;hcAutoInterv&gt;&lt;/hcAutoInterv&gt;
                        &lt;hcExceptDate&gt;&lt;/hcExceptDate&gt;
                        &lt;hcExceptReasonCode&gt;&lt;/hcExceptReasonCode&gt;
                        &lt;hcExceptText&gt;&lt;/hcExceptText&gt;
                        &lt;hcUnit&gt;&lt;/hcUnit&gt;
                        &lt;healthchAutoFlag&gt;&lt;/healthchAutoFlag&gt;
                        &lt;highestClientDataClassification&gt;&lt;/highestClientDataClassification&gt;
                        &lt;highestDataClassification&gt;&lt;/highestDataClassification&gt;
                        &lt;highestIbmDataClassification&gt;&lt;/highestIbmDataClassification&gt;
                        &lt;ibmCbnInterval&gt;&lt;/ibmCbnInterval&gt;
                        &lt;ibmCbnRequired&gt;&lt;/ibmCbnRequired&gt;
                        &lt;ibmCbnType&gt;&lt;/ibmCbnType&gt;
                        &lt;ibmCbnUnit&gt;&lt;/ibmCbnUnit&gt;
                        &lt;ibmPrivIDUnit&gt;&lt;/ibmPrivIDUnit&gt;
                        &lt;ibmPrivType&gt;&lt;/ibmPrivType&gt;
                        &lt;ibmQevFlag&gt;&lt;/ibmQevFlag&gt;
                        &lt;ibmQevInterval&gt;&lt;/ibmQevInterval&gt;
                        &lt;ibmQevUnit&gt;&lt;/ibmQevUnit&gt;
                        &lt;ibmUsersMax&gt;&lt;/ibmUsersMax&gt;
                        &lt;internetAccFlag&gt;&lt;/internetAccFlag&gt;
                        &lt;personalData&gt;&lt;/personalData&gt;
                        &lt;privIDFlag&gt;&lt;/privIDFlag&gt;
                        &lt;privIDInterv&gt;&lt;/privIDInterv&gt;
                        &lt;regulatoryRequirements&gt;&lt;/regulatoryRequirements&gt;
                        &lt;remediationtimeHi&gt;&lt;/remediationtimeHi&gt;
                        &lt;remediationtimeLo&gt;&lt;/remediationtimeLo&gt;
                        &lt;remediationtimeMd&gt;&lt;/remediationtimeMd&gt;
                        &lt;rerFlag&gt;&lt;/rerFlag&gt;
                        &lt;rerInterv&gt;&lt;/rerInterv&gt;
                        &lt;rerType&gt;&lt;/rerType&gt;
                        &lt;rerUnit&gt;&lt;/rerUnit&gt;
                        &lt;scExceptDate&gt;&lt;/scExceptDate&gt;
                        &lt;scExceptReasonCode&gt;&lt;/scExceptReasonCode&gt;
                        &lt;scExceptText&gt;&lt;/scExceptText&gt;
                        &lt;secExemptionDesc&gt;&lt;/secExemptionDesc&gt;
                        &lt;secExemptionFlag&gt;&lt;/secExemptionFlag&gt;
                        &lt;securityPackage&gt;&lt;/securityPackage&gt;
                        &lt;securityPolicyCategory&gt;&lt;/securityPolicyCategory&gt;
                        &lt;securityPolicyOther&gt;&lt;/securityPolicyOther&gt;
                        &lt;securityPolicyType&gt;&lt;/securityPolicyType&gt;
                        &lt;serverPurpose&gt;&lt;/serverPurpose&gt;
                        &lt;sharedIDFlag&gt;&lt;/sharedIDFlag&gt;
                        &lt;shrdExceptDate&gt;&lt;/shrdExceptDate&gt;
                        &lt;shrdExceptReasonCode&gt;&lt;/shrdExceptReasonCode&gt;
                        &lt;shrdExceptText&gt;&lt;/shrdExceptText&gt;
                        &lt;vitalBusProcessYN&gt;&lt;/vitalBusProcessYN&gt;
                     &lt;/OperatingSystemEnvironmentProfile&gt;
                     &lt;OperatingSystemIpAddress Action=&quot;Create&quot;&gt;
                        &lt;dotnotation&gt;&lt;/dotnotation&gt;
                        &lt;hostName&gt;&lt;/hostName&gt;
                        &lt;isPrimaryIpHost&gt;&lt;/isPrimaryIpHost&gt;
                        &lt;name&gt;&lt;/name&gt;
                        &lt;netMask&gt;&lt;/netMask&gt;
                        &lt;vsExceptDate&gt;&lt;/vsExceptDate&gt;
                        &lt;vsExceptReasonCode&gt;&lt;/vsExceptReasonCode&gt;
                        &lt;vsExceptText&gt;&lt;/vsExceptText&gt;
                        &lt;vulScanUnit&gt;&lt;/vulScanUnit&gt;
                        &lt;vulscanAutoFlag&gt;&lt;/vulscanAutoFlag&gt;
                        &lt;vulscanAutoInterval&gt;&lt;/vulscanAutoInterval&gt;
                     &lt;/OperatingSystemIpAddress&gt;
                  &lt;/ChildCI&gt;
               &lt;/OperatingSystem&gt;
               &lt;Subsystem Action=&quot;Create&quot;&gt;
                  &lt;Id&gt;3&lt;/Id&gt;
                  &lt;applSIDataType&gt;&lt;/applSIDataType&gt;
                  &lt;artifactType&gt;&lt;/artifactType&gt;
                  &lt;assetLifeCycleState&gt;&lt;/assetLifeCycleState&gt;
                  &lt;ciLifeCycleState&gt;&lt;/ciLifeCycleState&gt;
                  &lt;controlProductName&gt;&lt;/controlProductName&gt;
                  &lt;controlProductRelease&gt;&lt;/controlProductRelease&gt;
                  &lt;controlProductType&gt;&lt;/controlProductType&gt;
                  &lt;controlProductVendor&gt;&lt;/controlProductVendor&gt;
                  &lt;controlProductVersion&gt;&lt;/controlProductVersion&gt;
                  &lt;description&gt;&lt;/description&gt;
                  &lt;discontinuedDate&gt;&lt;/discontinuedDate&gt;
                  &lt;fqhn&gt;&lt;/fqhn&gt;
                  &lt;managed&gt;&lt;/managed&gt;
                  &lt;name&gt;&lt;/name&gt;
                  &lt;parentUID&gt;&lt;/parentUID&gt;
                  &lt;piFlag&gt;&lt;/piFlag&gt;
                  &lt;productModLevel&gt;&lt;/productModLevel&gt;
                  &lt;productName&gt;&lt;/productName&gt;
                  &lt;productPatchLevel&gt;&lt;/productPatchLevel&gt;
                  &lt;productRelease&gt;&lt;/productRelease&gt;
                  &lt;productVersion&gt;&lt;/productVersion&gt;
                  &lt;purgeDate&gt;&lt;/purgeDate&gt;
                  &lt;scanTime&gt;&lt;/scanTime&gt;
                  &lt;vendorName&gt;&lt;/vendorName&gt;
                  &lt;ChildCI&gt;
                     &lt;SubsystemContact Action=&quot;Create&quot;&gt;
                        &lt;contactUID&gt;&lt;/contactUID&gt;
                     &lt;/SubsystemContact&gt;
                     &lt;SubsystemEnvironmentProfile Action=&quot;Create&quot;&gt;
                        &lt;authFlag&gt;&lt;/authFlag&gt;
                        &lt;authExceptDate&gt;&lt;/authExceptDate&gt;
                        &lt;authExceptReasonCode&gt;&lt;/authExceptReasonCode&gt;
                        &lt;authExceptText&gt;&lt;/authExceptText&gt;
                        &lt;disasterRecSys&gt;&lt;/disasterRecSys&gt;
                        &lt;hcAutoInterv&gt;&lt;/hcAutoInterv&gt;
                        &lt;hcExceptDate&gt;&lt;/hcExceptDate&gt;
                        &lt;hcExceptReasonCode&gt;&lt;/hcExceptReasonCode&gt;
                        &lt;hcExceptText&gt;&lt;/hcExceptText&gt;
                        &lt;hcUnit&gt;&lt;/hcUnit&gt;
                        &lt;healthchAutoFlag&gt;&lt;/healthchAutoFlag&gt;
                        &lt;ibmCbnInterval&gt;&lt;/ibmCbnInterval&gt;
                        &lt;ibmCbnRequired&gt;&lt;/ibmCbnRequired&gt;
                        &lt;ibmCbnType&gt;&lt;/ibmCbnType&gt;
                        &lt;ibmCbnUnit&gt;&lt;/ibmCbnUnit&gt;
                        &lt;ibmPrivIDUnit&gt;&lt;/ibmPrivIDUnit&gt;
                        &lt;ibmPrivType&gt;&lt;/ibmPrivType&gt;
                        &lt;ibmQevFlag&gt;&lt;/ibmQevFlag&gt;
                        &lt;ibmQevInterval&gt;&lt;/ibmQevInterval&gt;
                        &lt;ibmQevUnit&gt;&lt;/ibmQevUnit&gt;
                        &lt;privIDFlag&gt;&lt;/privIDFlag&gt;
                        &lt;privIDInterv&gt;&lt;/privIDInterv&gt;
                        &lt;rerFlag&gt;&lt;/rerFlag&gt;
                        &lt;rerInterv&gt;&lt;/rerInterv&gt;
                        &lt;rerType&gt;&lt;/rerType&gt;
                        &lt;rerUnit&gt;&lt;/rerUnit&gt;
                        &lt;scExceptDate&gt;&lt;/scExceptDate&gt;
                        &lt;scExceptReasonCode&gt;&lt;/scExceptReasonCode&gt;
                        &lt;scExceptText&gt;&lt;/scExceptText&gt;
                        &lt;sharedIDFlag&gt;&lt;/sharedIDFlag&gt;
                        &lt;shrdExceptDate&gt;&lt;/shrdExceptDate&gt;
                        &lt;shrdExceptReasonCode&gt;&lt;/shrdExceptReasonCode&gt;
                        &lt;shrdExceptText&gt;&lt;/shrdExceptText&gt;
                        &lt;vitalBusProcessYN&gt;&lt;/vitalBusProcessYN&gt;
                     &lt;/SubsystemEnvironmentProfile&gt;
                  &lt;/ChildCI&gt;
               &lt;/Subsystem&gt;
            &lt;/TopLevelCI&gt;
            &lt;Relationship&gt;
               &lt;RelationshipName&gt;Hosted_by&lt;/RelationshipName&gt;
               &lt;sourceCIType&gt;OperatingSystem&lt;/sourceCIType&gt;
               &lt;targetCIType&gt;OperatingSystem&lt;/targetCIType&gt;
            &lt;/Relationship&gt;
            &lt;Relationship&gt;
               &lt;RelationshipName&gt;Runs_on&lt;/RelationshipName&gt;
               &lt;sourceCIType&gt;Subsystem&lt;/sourceCIType&gt;
               &lt;targetCIType&gt;OperatingSystem&lt;/targetCIType&gt;
            &lt;/Relationship&gt;
            &lt;Relationship&gt;
               &lt;RelationshipName&gt;Runs_on_hw&lt;/RelationshipName&gt;
               &lt;sourceCIType&gt;OperatingSystem&lt;/sourceCIType&gt;
               &lt;targetCIType&gt;PhysicalComputerSystem&lt;/targetCIType&gt;
            &lt;/Relationship&gt;
         &lt;/Customer&gt;
  &lt;/GACDWBulkLoadInterface&gt;
  </code></pre>
  <p>I have researched and come up with my VBA code here</p>
  <pre class="lang-vb prettyprint-override"><code>Sub ReadXML()
      Dim oXML As MSXML2.DOMDocument60
      Dim vaFile As Variant
      
      Set oXML = New MSXML2.DOMDocument60
      
      'Open Browse file dialog
      vaFile = Application.GetOpenFilename(&quot;XML Files (*.xml), *.xml&quot;, _
                    Title:=&quot;Select XML files&quot;, MultiSelect:=False)
      oXML.validateOnParse = True
      oXML.setProperty &quot;SelectionLanguage&quot;, &quot;XPath&quot;   ' necessary in version 3.0, possibly redundant here
      oXML.async = False
          
          
           If Not oXML.Load(vaFile) Then 'Load XML has gone bad
              Dim xPE        As Object    ' Set xPE = CreateObject(&quot;MSXML2.IXMLDOMParseError&quot;)
              Dim strErrText As String
              Set xPE = oXML.parseError
              With xPE
                 strErrText = &quot;Load error &quot; &amp; .ErrorCode &amp; &quot; xml file &quot; &amp; vbCrLf &amp; _
                 Replace(.URL, &quot;file:///&quot;, &quot;&quot;) &amp; vbCrLf &amp; vbCrLf &amp; _
                xPE.reason &amp; _
                &quot;Source Text: &quot; &amp; .srcText &amp; vbCrLf &amp; vbCrLf &amp; _
                &quot;Line No.:    &quot; &amp; .Line &amp; vbCrLf &amp; _
                &quot;Line Pos.: &quot; &amp; .linepos &amp; vbCrLf &amp; _
                &quot;File Pos.:  &quot; &amp; .filepos &amp; vbCrLf &amp; vbCrLf
              End With
              MsgBox strErrText, vbExclamation
              Set xPE = Nothing
              Exit Sub
          End If
          
      Debug.Print &quot;|&quot; &amp; oXML.XML &amp; &quot;|&quot;
      
      Dim nodeList  As MSXML2.IXMLDOMNodeList, iNode As MSXML2.IXMLDOMNode
      Dim Searched As String
      Searched = &quot;/*/*&quot;
      
      Set nodeList = oXML.SelectNodes(Searched)
      
      'Set Queries = oXML.DocumentElement.SelectNodes(Searched)
      
      For Each iNode In nodeList
           'Debug.Print &quot;&lt;&quot; &amp; iNode.BaseName &amp; &quot;&gt;&quot;
           Debug.Print &quot;&lt;&quot; &amp; iNode.nodeName &amp; &quot;&gt;&quot;
           
      Next
  </code></pre>
  <p>However, My problem is no matter what I come up with Xpath queries. None of them work except <code>\*</code> or <code>\.</code>
  I can't specific any path. Both <code>.SelectSingleNode</code> or <code>.SelectNodes</code> alway return length =0. Is there any problem with my code or my XML file or Xpath syntax?</p>