I have a stream of xml records which I process in scala using hadoopRDD and finally save in a single file However I need to sort those XMLs based on certain attributes before saving them in output file.
I thought of creating List with xml value and xml like below
Input
<Transaction>
<eventid>1234<eventId/>
<eventName>hello<eventName/>
.......
<Transaction/>
<Transaction>
<eventid>2345<eventId/>
<eventName>hi<eventName/>
.......
<Transaction/>
--- and so on
My idea is to create a list as {(1234, xml1),(2345,xml2)....} , sort on first element and save the second element to output file.
How can this be done in Scala , or is there a better approach to do this Thanks in advance for your suggestions and help