Parsing custom data into xml in Shell

Hi ,
I have data as below in a text file

{
'AAA' => {
       'A1' => 'a1 comment',
       'A2' => 'a2 comment'   
    },
'BBB' => {
      'B1' => 'b1 comment'
    },
'CCC' => {
      'C1' => 'c1 comment',
       'C2' => 'c2 comment',
       'C3' => 'c3 comment'
       'C4' => 'c4 cooment
    },
'DDD' => {
      'D1' => 'd1 comment'
    }
}

I want to parse this into a new XML file, so the output should look something like below,

<struct>
	<Table tName="AAA">
		<column name="A1">
			<columnComment>a1 comment</columnComment>
		</column>
		<column colName="A2">
			<columnComment>a2 comment</columnComment>
		</column>
	</Table>
	
	<Table tName="BBB">
		<column colName="B1">
			<columnComment>b1 comment</columnComment>
		</column>
	</Table>

</struct>

the command should be efficient and fast. :frowning:

is it feasible to do this?

This looks more like json to xml conversion. You have free tools online to do this. Please search once.

If you have huge data and need lot of this kind of processing, thenlook Postgresql ex. newest 9.5.
It has builtin really fast JSON and XML input parser using "COPY" and very fast output from JSONtoXML and XMLtoJSON. PG include datatypes JSON, JSONB, XML, ...

PG is SQL DB, but it's also one the fastest noSQL environment to handle JSON, CSV, XML, ... files.

Small json set I use jq to convert/parse but bigger data set I parse using PG command psql.