Im not sure this can be fixed by changing some configuration on what you have wither on the processor or the service level. Since the root element is not considered in the conversion from xml to Json, as workaround you can surround your xml with arbitrary root element with the ReplaceText Processor before the ConvertRecrod Processor:
Search Value: (?s)(^.*$)
Replacement Value: <root>$1</root>
Evaluation Mode: Entire Text
This will output the following xml:
And After ConvertRecord Prceossor :
Hope that helps. If it does, please Accept Solution.
Thank you SAMSL for your response. In the interest of scalability I was trying to avoid performing text manipulations. I ultimately decided to go with an XSLT transform since this processor is optimized for performing these types of operations, making it more scalable. I wanted to verify there wasn't an option within the XMLReader that I was missing, but it seems not.
On a side note, as an intellectual curiosity I also tried using the QueryRecord processor to see if I could select the outermost element in a query and slap wrapper text around it. But it seems there is no way to perform this task with an XMLReader because it can't discern the schema of the data, so "select * from flowfile" is the only thing that works apparently.
This seems like a good idea. I'll give this a try and test the performance against the XSLT transform. I've never used the JOLT processors before so this will be a good opportunity to experiment with one. Thanks for the idea.
I create an XMLRecordSetWriter in the Controller Services, then using a ConvertRecord processor I'm able to read the xml record and then immediately write it out with a new root tag, which I can then pass to my next processor. I discovered this when I was reading the documentation for the XMLRecordSetWriter. Very first line in the documentation. 😃