I have a xml like below.
Source XML:
<?xml version="1.0" encoding="Windows-1252"?>
<XML>
<Attributes>
<Attribute>
<Name>Collection</Name>
<Value />
</Attribute>
<Attribute>
<Name>A</Name>
<Value>Testing</Value>
</Attribute>
<Attribute>
<Name>B</Name>
<Value>Blank</Value>
</Attribute>
<Attribute>
<Name>C</Name>
<Value>11</Value>
</Attribute>
<Attribute>
<Name>D</Name>
<Value>NA</Value>
</Attribute>
<Attribute>
<Name>A</Name>
<Value>Testing1</Value>
</Attribute>
<Attribute>
<Name>B</Name>
<Value>Red</Value>
</Attribute>
<Attribute>
<Name>C</Name>
<Value>12</Value>
</Attribute>
<Attribute>
<Name>D</Name>
<Value>NAT</Value>
</Attribute>
</Attributes>
</XML>
From the above xml how I can I do this. I only want to group them in groups of 4. So first 4 (in the source xml) element where /attribute/Name='A' - /attribute/Name='D' will be in the first group. and next 4 where /attribute/Name='A' - /attribute/Name='D' will be in the second group .... like below
Thanks in Advance
Output
<Collection name="Collection" >
<ComplexAttr>
<Attr name="A" value="Testing" />
<Attr name="B" value="Blank" />
<Attr name="C" value="11" />
<Attr name="D" value="NA" />
</ComplexAttr>
<ComplexAttr >
<Attr name="A" value="Testing1" />
<Attr name="B" value="Red" />
<Attr name="C" value="12" />
<Attr name="D" value="NA" />
</ComplexAttr>
</Collection>