NiFi Ingest 25.2
NiFi Ingest

# Ingest XML

Many systems export data in XML format. This section describes how to ingest XML into Knowledge Discovery using NiFi Ingest.

The steps in this section assume that:

- You have one or more files each of which contains XML that should be parsed into one or more documents.
- The XML is not necessarily in Knowledge Discovery document format.

To ingest XML

1. Add a GetFileSystem processor to your data flow to retrieve the XML file(s).

   - Configure the location of your XML files by setting the property "Directory Paths".
   - Set the property "Parse XML" to FALSE.
   - If you are running a NiFi cluster, set the dynamic property `adv:FlowFileEmbedFiles` to TRUE. For more information about this property, see Advanced Connector Properties.
2. Add an ExecuteDocumentLua processor to the data flow.
3. Connect the "success" relationship of the GetFileSystem processor to the ExecuteDocumentLua processor.

4. Configure the ExecuteDocumentLua processor.

   1. Right-click the processor and click Configure.

      The Edit Processor dialog box opens.

   2. Click the Properties tab.
   3. Set the property Lua script function arguments to LuaFlowFileDocument, LuaProcessorSession.
   4. Set the property Route returned to to `returned`.
   5. Click Apply.

5. Continue configuring the ExecuteDocumentLua processor using the advanced configuration page.

   1. Right-click the processor and click Advanced.

      The advanced configuration page opens.

   2. In the Lua Samples area, click Reading and writing a FlowFile document > Parse XML from the content file(name), and return new documents.

   3. Copy the example script into the Lua code area.

      The script uses the parse_document_xml function to parse the input file. If the incoming FlowFile contains a filename, this is passed directly to the function. If the incoming FlowFile contains an embedded file, the data is read and passed to the parse_document_xml function as a string.

   4. At the beginning of the Lua script, modify the values in the `xmlParams` table so that they are suitable for your XML. For example, the `document_root_paths` option is a list of paths to elements that represent the root of a document in the input XML. For more information about these options, refer to the documentation for the parse_document_xml function.
   5. Click SAVE and then close the advanced configuration page.

6. Connect the "returned" relationship of the ExecuteDocumentLua processor to your ingestion pipeline. The resulting documents are output to the "returned" relationship because they are explicitly returned from the `handler` function in the Lua script.

   TIP: The original FlowFiles that were routed to the ExecuteDocumentLua processor are routed to the "success" relationship.

   To avoid indexing documents representing the original XML files, you could auto-terminate this relationship. However, if you are using a document registry service to ensure that documents are indexed in the correct sequence, route the "success" relationship to an UnregisterDocument processor. For more information about the document registry service, see Index Documents in the Correct Sequence.

7. Start the GetFileSystem and ExecuteDocumentLua processors.

Copyright 2018-2025 Open Text
Version 25.2 | Last updated April 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery NiFi Ingest 25.2

Topic Title: Ingest XML