When embedding Flatfile, this plugin should be deployed in a server-side listener. Learn more

Parameters

separator
string
default: "/"

The separator to use when joining or flattening nested attributes.

options.chunkSize
number
default: "10_000"

The chunkSize parameter allows you to specify the quantity of records to in each chunk.

options.parallel
number
default: "1"

The parallel parameter allows you to specify the number of chunks to process in parallel.

<?xml version="1.0" encoding="utf-8" ?>
<root>
    <person>
        <name>John</name>
        <age>30</age>
        <country>
            <name>USA</name>
            <code>US</code>
        </country>
    </person>
</root>

attributePrefix
string
default: "#"

The prefix to use when flattening attributes of XML tags.

<?xml version="1.0" encoding="utf-8" ?>
<root>
    <person>
        <name>John</name>
        <age>30</age>
        <country code="US">USA</country>
    </person>
</root>

transform
(row) => Record<string, any>

A function that takes a row and returns a transformed row. This is useful for adjusting the data before it is loaded into Flatfile.

<?xml version="1.0" encoding="utf-8" ?>
<root>
    <person>
        <name>John</name>
        <age>30</age>
        <country code="US">USA</country>
    </person>
    <person>
        <name>Jane</name>
        <age>25</age>
        <country code="CA">Canada</country>

    </person>

</root>

Usage

Listen for an XML file to be uploaded to Flatfile. The platform will then extract the file automatically. Once complete, the file will be ready for import in the Files area.

install
npm i @flatfile/plugin-xml-extractor
import
import { XMLExtractor } from "@flatfile/plugin-xml-extractor";
listener.js
listener.use(XMLExtractor());

Additional Options

The extractor can accept additional properties. Props will be passed along to the Sheet.js parsing engine.

listener.use(
  XMLExtractor({
    separator: "/",
    attributePrefix: "#",
    transform: (row: Record<string, any>) => {},
  })
);