Created on 02-12-2020 10:16 AM - last edited on 02-12-2020 10:58 AM by ask_bill_brooks
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
Created 02-13-2020 01:47 PM
@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
Created 02-14-2020 05:55 AM
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).