I have an XML file similar to this (with more nodes and details removed):
<?xml version="1.0" encoding="utf-8"?>
<Message xmlns="http://www.theia.org.uk/ILR/2011-12/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<CollectionDetails>
<Collection>ILR</Collection>
<Year>1112</Year>
<FilePreparationDate>2011-10-06</FilePreparationDate>
</CollectionDetails>
<Source>
<ProtectiveMarking>PROTECT-PRIVATE</ProtectiveMarking>
</Source>
</Header>
<SourceFiles>
<SourceFile>
<SourceFileName>A10004705001112004401.ER</SourceFileName>
<FilePreparationDate>2011-10-05</FilePreparationDate>
</SourceFile>
</SourceFiles>
<LearningProvider>
<UKPRN>10004705</UKPRN>
<UPIN>107949</UPIN>
</LearningProvider>
<Learner>
<ULN>4682272097</ULN>
<GivenNames>Peter</GivenNames>
<LearningDelivery>
<LearnAimRef>60000776</LearnAimRef>
</LearningDelivery>
<LearningDelivery>
<LearnAimRef>ZPROG001</LearnAimRef>
</LearningDelivery>
</Learner>
<Learner>
<ULN>3072094321</ULN>
<GivenNames>Thomas</GivenNames>
<LearningDelivery>
<LearnAimRef>10055320</LearnAimRef>
</LearningDelivery>
<LearningDelivery>
<LearnAimRef>10002856</LearnAimRef>
</LearningDelivery>
<LearningDelivery>
<LearnAimRef>1000287X</LearnAimRef>
</LearningDelivery>
</Learner>
</Message>
I need to filter this so that only Learner records that have a child LearningDelivery LearnAimRef of ZPROG001 will show so the output in this case would be the first learner but not the second:
<?xml version="1.0" encoding="utf-8"?>
<Message xmlns="http://www.theia.org.uk/ILR/2011-12/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<CollectionDetails>
<Collection>ILR</Collection>
<Year>1112</Year>
<FilePreparationDate>2011-10-06</FilePreparationDate>
</CollectionDetails>
<Source>
<ProtectiveMarking>PROTECT-PRIVATE</ProtectiveMarking>
</Source>
</Header>
<SourceFiles>
<SourceFile>
<SourceFileName>A10004705001112004401.ER</SourceFileName>
<FilePreparationDate>2011-10-05</FilePreparationDate>
</SourceFile>
</SourceFiles>
<LearningProvider>
<UKPRN>10004705</UKPRN>
<UPIN>107949</UPIN>
</LearningProvider>
<Learner>
<ULN>4682272097</ULN>
<GivenNames>Peter</GivenNames>
<LearningDelivery>
<LearnAimRef>60000776</LearnAimRef>
</LearningDelivery>
<LearningDelivery>
<LearnAimRef>ZPROG001</LearnAimRef>
</LearningDelivery>
</Learner>
</Message>
I have looked into how to do this and believe the correct way to do this is to use an XSL transform to process the xml and output as needed to a new file (Doing this in c#). After a couple of hours trying to wrap my head around the XSLT syntax I am still stuck and can't get the output I want. Any help much appreciated.