Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to extract multiple records from a single xml file such that each record can be stored as a separate JSON String?

Highlighted

How to extract multiple records from a single xml file such that each record can be stored as a separate JSON String?

New Contributor

@Shu

<Transaction>

<StoreName>Amazon</StoreName>

<RetailStoreID>56</RetailStoreID>

<SequenceNumber>2</SequenceNumber>

<RetailTransaction>

<LineItem>

<SequenceNumber>7</SequenceNumber>

<Sale>

<UnitPrice>58.02</UnitPrice>

<Amount>1972.68</Amount>

<Quantity>34</Quantity>

</Sale>

</LineItem>

<LineItem>

<SequenceNumber>8</SequenceNumber>

<Sale>

<UnitPrice>26.84</UnitPrice>

<Amount>187.88</Amount>

<Quantity>7</Quantity>

</Sale>

</LineItem>

</RetailTransaction>

</Transaction>


This is the data format. I am looking for 2 separate Json strings in the following format:

{"RetailStoreID":"56","quantity":"34","sales":"1972.68"} and {"RetailStoreID":"56","quantity":"7","sales":"187.88"}

but I am getting only the first record. The Nifi flow goes from EvaluateXPath -> AttributesToJson --> ReplaceText. Please let me know if you can help with this.


Thanks,

Likhith.