Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

Nifi - How to parse XML payload from FlowFile and insert fields into the database along with XML as well in

New Contributor

We are trying to parse an XML payload and trying to insert into fields along with full XML payload but it is not working, the flow looks like GenerateFlowFile → ConvertRecord → PutDatabaseRecord


New Contributor

@mburgess pls help!


We are kind of stuck, we are trying to process an XML file, the requirement is to load XML tags into individual columns and also the full XML into a clob column into a table in oracle DB.

We have tried:

1. GenerateFlowFile(For testing purpose, have put XML in customtext field) --> ConvertRecord(XML - > Avro) --> PutDatabaseRecord

Master Guru

For small XML files, you could use ExtractText to get the entire content into an attribute, then UpdateRecord with an XMLReader, adding a property for your new field (let's say "/content") and whatever writer you wish. You will have to specify the output schema for the writer, to include all the fields parsed by the XMLReader in addition to a CLOB/BLOB/String "content" field. If you want to exclude fields from the XML then just exclude them from the output schema. Then you can use a similar Reader (AvroReader if you use an AvroRecordSetWriter, e.g.) in PutDatabaseRecord.


If this doesn't work for your use case, you may need to use SplitXml and work on individual records. This will degrade the performance of PutDatabaseRecord unless you merge the records back together later (using MergeRecord for example).