This is the VBA code I’m currently using to import an XML into my workbook (which works just fine):
Sub matomoImportXML()
Dim matomoXML As Workbook
Application.DisplayAlerts = False
Set matomoXML = Workbooks.OpenXML(FileName:=matomo_xml, LoadOption:=xlXmlLoadImportToList)
Application.DisplayAlerts = True
matomoXML.Sheets(1).UsedRange.Copy report.Sheets(matomo_data).Range("A1")
matomoXML.Close False
End Sub
And this is an example of the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<result>
<row>
<label>lp_total_pageviews=1 - my-website.com/please-verify-you-age-to-enter/ - Others</label>
<nb_uniq_events_eventaction>118</nb_uniq_events_eventaction>
<nb_uniq_events_eventcategory>118</nb_uniq_events_eventcategory>
<nb_uniq_corehome_visitip>118</nb_uniq_corehome_visitip>
<level>3</level>
<Events_EventAction>lp_total_pageviews=1</Events_EventAction>
<Events_EventCategory>my-website.com%2Fplease-verify-you-age-to-enter%2F</Events_EventCategory>
<is_summary>1</is_summary>
<CoreHome_VisitIp>Others</CoreHome_VisitIp>
</row>
<row>
<label>lp_total_clicks=1 - my-website.com/please-verify-you-age-to-enter-rs/ - xxxx:1009:b00a:6fd8:d937:5eb2:7563:de56</label>
<nb_uniq_events_eventaction>3</nb_uniq_events_eventaction>
<nb_uniq_events_eventcategory>3</nb_uniq_events_eventcategory>
<nb_uniq_corehome_visitip>3</nb_uniq_corehome_visitip>
<level>3</level>
<Events_EventAction>lp_total_clicks=1</Events_EventAction>
<Events_EventCategory>my-website.com%2Fplease-verify-you-age-to-enter-rs%2F</Events_EventCategory>
<CoreHome_VisitIp>XXXX:1009:b00a:6fd8:d937:5eb2:7563:de56</CoreHome_VisitIp>
</row>
</result>
Now, before I import and copy it to my workbook, I have to loop through the XML and delete the child node <is_summary>some value</is_summary> completely (if it exist).
I’ve been trying out multiple solutions I found online, but so far unsuccessful.
Any help would be greatly appreciated!