Convert varying xml to another xml



I have an input xml which looks like



<Root>
<Monday>Monday<Monday>
<Indicator>true<Indicator>
<Value>1<Value>
<Tuesday>Tuesday<Tuesday>
<Indicator>true<Indicator>
<Value>2<Value>
<Wednesday>Wednesday<Wednesday>
<Indicator>true<Indicator>
<Value>3<Value>
</Root>


must be converted to the output xml which is



<Root>
<Monday>Monday<Monday>
<Value>1<Value>
<Tuesday>Tuesday<Tuesday>
<Value>2<Value>
<Wednesday>Wednesday<Wednesday>
<Value>3<Value>
</Root>


but the problem is the input xml can vary..sometimes it might be



<Root>
<Monday>Monday<Monday>
<Indicator>true<Indicator>
<Value>1<Value>
<Thursday>Thursday<Thursday>
<Indicator>true<Indicator>
<Value>4<Value>
</Root>


now the output must be



<Root>
<Monday>Monday<Monday>
<Value>1<Value>
<Thursday>Thursday<Thursday>
<Value>4<Value>
</Root>


And also I have the list of valid tags like Monday,Tuesday etc, which can come in the input xml in an arraylist in java.Any ideas on how to accomplish this.


No comments:

Post a Comment