Precise da sua ajuda para dividir um arquivo XML com vários nós principais em arquivos XML com um único nó pai em cada um deles.
Abaixo está o arquivo de amostra com 2 registros:
<?xml version='1.0' encoding='UTF-8'?>
<Record xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AddressBlock>
<AddressOne>.....</AddressOne>
<AddressTwo />
<CityCounty>.....</CityCounty>
<County>.....</County>
<Country>.....</Country>
<PostCode>.....</PostCode>
</AddressBlock>
<ContactName>
<Prefix />
<FirstName>.....</FirstName>
<MiddleName />
<LastCompanyName>.....</LastCompanyName>
<Suffix />
</ContactName>
<Injury>
<SoftTissue>
false
</SoftTissue>
<BoneInjury>
false
</BoneInjury>
<Whiplash>
false
</Whiplash>
<Respiratory xsi:nil="true" />
<Deafness xsi:nil="true" />
<VibrationInjury xsi:nil="true" />
<Dermatitis xsi:nil="true" />
<Other>
false
</Other>
<InjuryDetails>.....
</InjuryDetails>
</Injury>
<Repairs>
<VehicleDamaged xsi:nil="true" />
<VehicleDamagedDetails xsi:nil="true" />
</Repairs>
</Record>
<Record xmlns="http://tempuri.org/XMLSchema.xsd">
<AddressBlock>
<AddressOne>.....</AddressOne>
<AddressTwo />
<CityCounty>.....</CityCounty>
<County>.....</County>
<Country>.....</Country>
<PostCode>.....</PostCode>
</AddressBlock>
<ContactName>
<Prefix />
<FirstName>.....</FirstName>
<MiddleName />
<LastCompanyName>.....</LastCompanyName>
<Suffix />
</ContactName>
<Injury>
<SoftTissue>
false
</SoftTissue>
<BoneInjury>
false
</BoneInjury>
<Whiplash>
false
</Whiplash>
<Respiratory xsi:nil="true" />
<Deafness xsi:nil="true" />
<VibrationInjury xsi:nil="true" />
<Dermatitis xsi:nil="true" />
<Other>
false
</Other>
<InjuryDetails>.....
</InjuryDetails>
</Injury>
<Repairs>
<VehicleDamaged xsi:nil="true" />
<VehicleDamagedDetails xsi:nil="true" />
</Repairs>
</Record>
Preciso da sua ajuda para dividi-lo em 2 arquivos com 1 registro em cada (com base no nó pai 'Gravar'. Da mesma forma, o número de registros no arquivo fonte (consolidado) pode variar .