I am trying to re-arrange all the attributes of the XML file. Need to group all the attributes of each node.
<?xml version="1.0" encoding="UTF-8"?> <subject> <param name="A" value="a" /> <study> <param name="AA" value="aa" /> <series> <param name="AAA" value="aaa" /> <dataset> <param name="AAAA" value="aaaa" /> <data> <param name="AAAAA" value="aaaaa" /> </data> </dataset> <param name="BBB" value="bbb" /> </series> </study> <param name="B" value="b" /> </subject>
Here is the required output XML file:
<?xml version="1.0" encoding="UTF-8"?> <subject> <param name="A" value="a" /> <param name="B" value="b" /> <study> <param name="AA" value="aa" /> <series> <param name="AAA" value="aaa" /> <param name="BBB" value="bbb" /> <dataset> <param name="AAAA" value="aaaa" /> <data> <param name="AAAAA" value="aaaaa" /> </data> </dataset> </series> </study> </subject>
Can this be possible with XML DOM in JAVA?