This is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2" xmlns:sdt="urn:oasis:names:specification:ubl:schema:xsd:SpecializedDatatypes-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 UBL-Invoice-2.0.xsd">
<cbc:ID>102165444</cbc:ID>
<cac:InvoiceLine>
<cbc:ID>1.0000</cbc:ID>
<cbc:Note />
<cbc:InvoicedQuantity unitCode="CT">1.0000</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="DKK">142.3900</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="DKK">138.24</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="DKK">142.39</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="DKK">7.20</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyID="320" schemeID="urn:oioubl:id:taxcategoryid-1.1">3645</cbc:ID>
<cac:TaxScheme>
<cbc:ID schemeAgencyID="320" schemeID="urn:oioubl:id:taxschemeid-1.1">140</cbc:ID>
<cbc:Name>Afgift</cbc:Name>
<cbc:TaxTypeCode listAgencyID="320" listID="urn:oioubl:codelist:taxtypecode-1.1">StandardRated</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
</cac:InvoiceLine>
<cbc:ID>2.0000</cbc:ID>
<cbc:Note />
<cbc:InvoicedQuantity unitCode="CT">1.0000</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="DKK">142.3900</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="DKK">138.24</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="DKK">142.39</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="DKK">7.20</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyID="320" schemeID="urn:oioubl:id:taxcategoryid-1.1">3645</cbc:ID>
<cac:TaxScheme>
<cbc:ID schemeAgencyID="320" schemeID="urn:oioubl:id:taxschemeid-1.1">140</cbc:ID>
<cbc:Name>Afgift</cbc:Name>
<cbc:TaxTypeCode listAgencyID="320" listID="urn:oioubl:codelist:taxtypecode-1.1">StandardRated</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="DKK">35.60</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="DKK">142.39</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="DKK">35.60</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyID="320" schemeID="urn:oioubl:id:taxcategoryid-1.1">StandardRated</cbc:ID>
<cbc:Percent>25</cbc:Percent>
<cac:TaxScheme>
<cbc:ID schemeAgencyID="320" schemeID="urn:oioubl:id:taxschemeid-1.1">63</cbc:ID>
<cbc:Name>Moms</cbc:Name>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
</cac:InvoiceLine>
</Invoice>
As you can see, the file has an id, several 'Invoice lines', that each have their own id along with other child elements.
What I want to do is create a csv file with a row for each invoice line with information from specific nested elements. The challenge is that for each line there can be several 'TaxTotal' child-elements. In that case I'd want another line with that information like this:
ID;/InvoiceLine/ID;InvoiceLine/InvoicedQuantity;/InvoiceLine/LineExtensionAmount;/InvoiceLine/TaxTotal/TaxAmount;/InvoiceLine/TaxTotal/TaxSubtotal/TaxableAmount /InvoiceLine/TaxTotal/TaxSubtotal/TaxAmount ;/InvoiceLine/TaxTotal/TaxSubtotal/TaxCategory/ID;/InvoiceLine/TaxTotal/TaxSubtotal/TaxCategory/Percent;/InvoiceLine/TaxTotal/TaxSubtotal/TaxCategory/TaxScheme/ID;/InvoiceLine/TaxTotal/TaxSubtotal/TaxCategory/TaxScheme/Name
102165444;1;1;142,39;138,24;142,39;7,20;3645,00;;140;Afgift
102165444;2;1;142,39;138,24;142,39;7,20;3646,00;;140;Afgift
102165444;2;1;142,39;35,60;142,39;35,60;StandardRated;25,00;63;Moms
How do I accomplish this?
TaxTotalelement?