Hi,
my xml files looks something like this
<Instance Name="New York">
<Description></Description>
<Instance Name="A">
<Description></Description>
<PropertyValue Key="false" Name="Building A" />
</Instance>
<Instance Name="B">
<Description></Description>
<PropertyValue Key="false" Name="Building B" />
</Instance>
<PropertyValue Key="false" Name="random" />
<PropertyValue Key="false" Name="blabla" />
<PropertyValue Key="false" Name="blabla2" />
</Instance>
I need to grep all the lines between </Instance> and </Instance> {the 3 proeprty values, there cna be 4 or more, and place them on top between </Description> and <Instance, so it becomes like this
<Instance Name="New York">
<Description></Description>
<PropertyValue Key="false" Name="random" />
<PropertyValue Key="false" Name="blabla" />
<PropertyValue Key="false" Name="blabla2" />
<Instance Name="A">
<Description></Description>
<PropertyValue Key="false" Name="Building A" />
</Instance>
<Instance Name="B">
<Description></Description>
<PropertyValue Key="false" Name="Building B" />
</Instance>
</Instance>
[/CODE]
For the notes, There can be more than 1 parent in file. The Instance name will also be different than New York, but what I need to highlight is the string matching condition. In short, a complete file may look like this
<Instance Name="New York">
<Description></Description>
<Instance Name="A">
<Description></Description>
<PropertyValue Key="false" Name="Building A" />
</Instance>
<Instance Name="B">
<Description></Description>
<PropertyValue Key="false" Name="Building B" />
</Instance>
<PropertyValue Key="false" Name="random" />
<PropertyValue Key="false" Name="blabla" />
<PropertyValue Key="false" Name="blabla2" />
</Instance>
<Instance Name="Mumbai">
<Description></Description>
<Instance Name="C">
<Description></Description>
<PropertyValue Key="false" Name="Building C" />
</Instance>
<Instance Name="D">
<Description></Description>
<PropertyValue Key="false" Name="Building D" />
</Instance>
<PropertyValue Key="false" Name="absolute" />
<PropertyValue Key="false" Name="perl" />
<PropertyValue Key="false" Name="xml" />
</Instance>
In which case, the result needs to be like this
<Instance Name="New York">
<Description></Description>
<PropertyValue Key="false" Name="random" />
<PropertyValue Key="false" Name="blabla" />
<PropertyValue Key="false" Name="blabla2" />
<Instance Name="A">
<Description></Description>
<PropertyValue Key="false" Name="Building A" />
</Instance>
<Instance Name="B">
<Description></Description>
<PropertyValue Key="false" Name="Building B" />
</Instance>
</Instance>
<Instance Name="Mumbai">
<Description></Description>
<PropertyValue Key="false" Name="absolute" />
<PropertyValue Key="false" Name="perl" />
<PropertyValue Key="false" Name="xml" />
<Instance Name="C">
<Description></Description>
<PropertyValue Key="false" Name="Building C" />
</Instance>
<Instance Name="D">
<Description></Description>
<PropertyValue Key="false" Name="Building D" />
</Instance>
</Instance>
I wonder if this is possible, please help. Thank you very much.Really appreciate it.