java - Compare two almost similar xml files and then add tags missing in first xml file -


i have xml files abc.xml & 123.xml similar, mean has same content, second 1 i.e, 123.xml has more content earlier one. want read both files using java, , compare whether content present in abc.xml each tag same in 123.xml, , if 123.xml has additional tags add abc.xml same remove tags 123.xml if abc.xml doesnt have it.

i have 2 configuration files in xml old , new version. in new 1 tags added or removed , want generate xml file using content of old xml file , having xml schema of new xml file. hope bit clear now.

that litle bit vague. there plenty off ways this. espacialy when think how merge should done. 1 side overriding other one? mean remove of tags can happen when newer file has less.

here 2 approaches how handle this:

  1. use existing diff , patch can find in version control system. use java run diff , patch application on console. in case make diff. if there difference use create patch patch file describing changes , apply patch.

  2. if wil in java, not try parse file , work serialized on it. drive crazy. use kind of marshalling jax-b convert xml in pojo. can compare pojos , add or remove missing elements target pojo , serialize xml.

hope starting point further investigation ;)


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -