How to read XML element (content) from binary file

Hi, I can’t read xml file element. I see option of file but I dont see content body. Can You told me why?

My workflow

The output returned by the last node

ERROR: No json property “data” does not exists on item!

There is xml file:

<?xml version="1.0"?>
<ImpulsEdiMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <StandardBusinessDocumentHeader>
    <HeaderVersion>1</HeaderVersion>
    <DocumentIdentification>
      <Standard>IMPULS.EDI</Standard>
      <DocumentMessage>InvoiceMessage</DocumentMessage>
      <DocumentMessageVersion>1.0</DocumentMessageVersion>
      <CreationDateAndTime>2022-10-04T08:44:20.0268781+02:00</CreationDateAndTime>
    </DocumentIdentification>
  </StandardBusinessDocumentHeader>
  <InvoiceMessage>
    <EntityIdentification>
      <EntityId>FV/000026/10/22</EntityId>
      <OwnerGln>5907524060006</OwnerGln>
      <ImpulsDocumentTypeId>60</ImpulsDocumentTypeId>
    </EntityIdentification>
    <InvoiceHeader>
      <InvoiceNumber>FV/000026/10/22</InvoiceNumber>
      <InvoiceDate>2022-10-03T00:00:00</InvoiceDate>
      <SalesDate>2022-10-03T00:00:00</SalesDate>
      <DuplicateDate xsi:nil="true" />
      <InvoiceCurrency>PLN</InvoiceCurrency>
      <InvoicePaymentDueDate>2022-11-27T00:00:00</InvoicePaymentDueDate>
      <InvoicePaymentTerms>55</InvoicePaymentTerms>
      <ImpulsPaymentMethodCode>1</ImpulsPaymentMethodCode>
      <SplitPayment>N</SplitPayment>
      <InvoicePostDate xsi:nil="true" />
      <ImpulsDocumentFunctionCode>O</ImpulsDocumentFunctionCode>
      <Delivery>
        <ImpulsDeliveryMethodCode>10</ImpulsDeliveryMethodCode>
        <DeliveryInstructions>Transport lądowy</DeliveryInstructions>
        <ShipToGLN>5900001350201</ShipToGLN>
        <Address>
          <Name>Jeronimo Martins Polska S.A.</Name>
          <StreetAndNumber>Innowacyjna 6</StreetAndNumber>
          <City>Sosnowiec</City>
          <PostalCode>41-218</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <IncotermsDeliveryCode>DAP</IncotermsDeliveryCode>
      </Delivery>
      <Buyer>
        <GLN>5900001300015</GLN>
        <Address>
          <Name>JERONIMO MARTINS POLSKA SPÓŁKA AKCYJNA</Name>
          <StreetAndNumber>ul. Żniwna 5</StreetAndNumber>
          <City>Kostrzyn</City>
          <PostalCode>62-025</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>7791011327</TaxId>
      </Buyer>
      <Payer>
        <GLN>5900001300015</GLN>
        <Address>
          <Name>JERONIMO MARTINS POLSKA SPÓŁKA AKCYJNA</Name>
          <StreetAndNumber>ul. Żniwna 5</StreetAndNumber>
          <City>Kostrzyn</City>
          <PostalCode>62-025</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>7791011327</TaxId>
      </Payer>
      <Invoicee>
        <GLN>5900001300015</GLN>
        <Address>
          <Name>JERONIMO MARTINS POLSKA SPÓŁKA AKCYJNA</Name>
          <StreetAndNumber>ul. Żniwna 5</StreetAndNumber>
          <City>Kostrzyn</City>
          <PostalCode>62-025</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>7791011327</TaxId>
      </Invoicee>
      <Seller>
        <GLN>5907524060006</GLN>
        <Address>
          <Name>ZAKŁAD PRZEMYSŁU MIĘSNEGO BIERNACKI SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ</Name>
          <StreetAndNumber>ul. Dworcowa 47D</StreetAndNumber>
          <City>Golina</City>
          <PostalCode>63-200</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>6172148186</TaxId>
        <AccountNumber>PL50 1140 1993 0000 5212 7800 1033</AccountNumber>
        <CodeByBuyer>636848</CodeByBuyer>
      </Seller>
      <Payee>
        <GLN>5907524060006</GLN>
        <Address>
          <Name>ZAKŁAD PRZEMYSŁU MIĘSNEGO BIERNACKI SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ</Name>
          <StreetAndNumber>ul. Dworcowa 47D</StreetAndNumber>
          <City>Golina</City>
          <PostalCode>63-200</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>6172148186</TaxId>
        <AccountNumber>PL50 1140 1993 0000 5212 7800 1033</AccountNumber>
      </Payee>
      <SellerHeadquarters>
        <GLN>5907524060006</GLN>
        <Address>
          <Name>ZAKŁAD PRZEMYSŁU MIĘSNEGO BIERNACKI SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ</Name>
          <StreetAndNumber>ul. Dworcowa 47D</StreetAndNumber>
          <City>Golina</City>
          <PostalCode>63-200</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>6172148186</TaxId>
      </SellerHeadquarters>
      <OrderedBy>
        <GLN>5900001300015</GLN>
        <Address>
          <Name>JERONIMO MARTINS POLSKA SPÓŁKA AKCYJNA</Name>
          <StreetAndNumber>ul. Żniwna 5</StreetAndNumber>
          <City>Kostrzyn</City>
          <PostalCode>62-025</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>7791011327</TaxId>
      </OrderedBy>
      <Sender>
        <GLN>5907524060006</GLN>
        <Address>
          <Name>ZAKŁAD PRZEMYSŁU MIĘSNEGO BIERNACKI SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ</Name>
          <StreetAndNumber>ul. Dworcowa 47D</StreetAndNumber>
          <City>Golina</City>
          <PostalCode>63-200</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>6172148186</TaxId>
      </Sender>
      <Receiver>
        <GLN>5900001350201</GLN>
        <Address>
          <Name>Jeronimo Martins Polska S.A.</Name>
          <StreetAndNumber>Innowacyjna 6</StreetAndNumber>
          <City>Sosnowiec</City>
          <PostalCode>41-218</PostalCode>
          <CountryCode>PL</CountryCode>
        </Address>
        <TaxId>7791011327</TaxId>
      </Receiver>
    </InvoiceHeader>
    <InvoiceLines>
      <InvoiceLine>
        <LineItem>
          <LineNumber>1</LineNumber>
          <ItemIdentification>
            <GTIN>5907524063328</GTIN>
            <BuyerIndexCode>235414</BuyerIndexCode>
            <BuyerIndexName>HAMBURGER WOŁOWY 6x200g</BuyerIndexName>
            <CommercialVersion>52222778</CommercialVersion>
            <SupplierIndexCode>03010431</SupplierIndexCode>
            <SupplierIndexName>HAMBURGER WOŁOWY 6x200g</SupplierIndexName>
          </ItemIdentification>
          <UnitOfMeasure>szt</UnitOfMeasure>
          <InvoiceUnitPacksize xsi:nil="true" />
          <Quantity>
            <InvoiceQuantity>792</InvoiceQuantity>
            <DeliveredQuantity xsi:nil="true" />
          </Quantity>
          <InvoicePriceWithAmounts>
            <TaxAmount>0</TaxAmount>
            <NetAmount>4078.80</NetAmount>
            <InvoiceUnitNetPrice>5.15</InvoiceUnitNetPrice>
            <InvoiceUnitGrossPrice>5.15</InvoiceUnitGrossPrice>
            <InvoiceUnitRetailPrice>5.15</InvoiceUnitRetailPrice>
          </InvoicePriceWithAmounts>
          <InvoiceDepositAmount xsi:nil="true" />
          <TaxCategory>
            <Rate>0</Rate>
            <CategoryCode>S</CategoryCode>
          </TaxCategory>
          <PKWiUCode>10.61.33.0</PKWiUCode>
          <CnCode>16025010</CnCode>
          <PreviousDepositAmount xsi:nil="true" />
          <ExpirationDate xsi:nil="true" />
          <ProductionDate xsi:nil="true" />
          <UtilizationFeeAmount>0</UtilizationFeeAmount>
        </LineItem>
        <LineOrders>
          <ReferencedOrder>
            <BuyerOrderNumber>2023196022</BuyerOrderNumber>
            <SupplierOrderNumber>ZKK_B/1372/09/22</SupplierOrderNumber>
            <BuyerOrderDate>2022-09-29T00:00:00</BuyerOrderDate>
            <OrderLineNumber>1</OrderLineNumber>
          </ReferencedOrder>
        </LineOrders>
        <LineDespatches>
          <ReferencedDespatch>
            <DespatchNumber>WZ/5991/26/N</DespatchNumber>
            <DespatchDocumentDate>2022-10-01T00:00:00</DespatchDocumentDate>
            <DeliveryDate xsi:nil="true" />
          </ReferencedDespatch>
        </LineDespatches>
      </InvoiceLine>
    </InvoiceLines>
    <InvoiceSummary>
      <TotalLines>1</TotalLines>
      <TotalAmountsSummary>
        <TotalNetAmount>4078.80</TotalNetAmount>
        <TotalTaxableBasis>4078.80</TotalTaxableBasis>
        <TotalTaxAmount>0</TotalTaxAmount>
        <TotalGrossAmount>4078.80</TotalGrossAmount>
      </TotalAmountsSummary>
      <TaxSummary>
        <TaxSummaryLines>
          <TaxSummaryLine>
            <Tax>
              <TaxCategory>
                <Rate>0</Rate>
                <CategoryCode>S</CategoryCode>
              </TaxCategory>
              <TaxAmount>0</TaxAmount>
              <TaxableBasis>4078.80</TaxableBasis>
              <TaxableAmount>4078.80</TaxableAmount>
              <GrossAmount>4078.80</GrossAmount>
            </Tax>
            <CorrectionTaxAmount xsi:nil="true" />
            <CorrectionTaxableBasis xsi:nil="true" />
          </TaxSummaryLine>
        </TaxSummaryLines>
      </TaxSummary>
    </InvoiceSummary>
  </InvoiceMessage>
</ImpulsEdiMessage>

Information about n8n setup

  • n8n version:0.198.2
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: desktop app

You need to use the xml node in order to transform it to json and pickt it from there.

should work fine, maybe this could be an issue <InvoicePostDate xsi:nil=“true” />

1 Like

I used xml node in this example. And I have this err:

But, it’s weird, because when I do JSON to XML, thats worked, but return me only some settings of file, not all content XML. I don’t understand.

As an assumption you could try this: http request node, xml node. But you seem to have an error in the xml on line 11.

Hi @Krystian_Klopocki, the XML node would read XML from a JSON data field of your item, not directly from a file. If you need to read XML from a file, you will need an additional Move Binary Data node in your workflow, so you essentially have three steps:

  1. Obtain the file (for example using the Read Binary File node or the HTTP Request node)
  2. Read the file content (using Move Binary Data)
  3. Parse the XML data (using the XML node)

I’ve posted an example of a workflow for this on the other thread over here: Read xml file - #8 by MutedJam

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.