I receive XML files which I need to remove data before forwarding them to clients. in the instance below, if I supply a parameter value for ref ie only the first 6 digits , how can I delete the ReturnedDebitItem that doesn't starte with the parameter value ie <> Left (ref , 6) Below is the before and what I want to get to if I supply 121212 as the parameter. opening and closing tags removed to post
"BACSDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="newbacs-advices.xsd""
"Data"
"ARUDD"
"Header reportType="REFT1019" adviceNumber="999" currentProcessingDate="2018-01-03" /"
"AddresseeInformation name="SOME COMPANY" /"
"ServiceLicenseInformation userName="SOME COMPANY" userNumber="000000" /"
"Advice"
"OriginatingAccountRecords"
"OriginatingAccountRecord"
"OriginatingAccount name="SOME COMPANY ACCOUNT" number="11111111" sortCode="11-11-11" type="0" bankName="BANK" branchName="SOME TOWN" /"
"ReturnedDebitItem ref="121212TEST1" transCode="17" returnCode="1363" returnDescription="INSTRUCTION CANCELLED" originalProcessingDate="2017-12-29" valueOf="60.00" currency="GBP""
"PayerAccount number="12345678" ref="121212TEST1" name="JOHN" sortCode="12-34-56" /"
"/ReturnedDebitItem"
"ReturnedDebitItem ref="121212TEST2" transCode="17" returnCode="5363" returnDescription="NO ACCOUNT" originalProcessingDate="2017-12-29" valueOf="60.00" currency="GBP""
"PayerAccount number="87654321" ref="121212TEST2" name="PAUL" sortCode="09-09-09" /"
"/ReturnedDebitItem"
"ReturnedDebitItem ref="321654TEST1" transCode="17" returnCode="1363" returnDescription="INSTRUCTION CANCELLED" originalProcessingDate="2017-12-29" valueOf="30.00" currency="GBP""
"PayerAccount number="01100110" ref="321654TEST1" name="PETER" sortCode="01-01-01" /"
"/ReturnedDebitItem"
"ReturnedDebitItem ref="121212TEST3" transCode="17" returnCode="1363" returnDescription="INSTRUCTION CANCELLED" originalProcessingDate="2017-12-29" valueOf="60.00" currency="GBP""
"PayerAccount number="33333333" ref="121212TEST3" name="MARY" sortCode="33-33-33" /"
"/ReturnedDebitItem"
"/OriginatingAccountRecord"
"/OriginatingAccountRecords"
"/Advice"
"/ARUDD"
"/Data"
"/BACSDocument"
End up with
"BACSDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="newbacs-advices.xsd""
"Data"
"ARUDD"
"Header reportType="REFT1019" adviceNumber="999" currentProcessingDate="2018-01-03" /"
"AddresseeInformation name="SOME COMPANY" /"
"ServiceLicenseInformation userName="SOME COMPANY" userNumber="000000" /"
"Advice"
"OriginatingAccountRecords"
"OriginatingAccountRecord"
"OriginatingAccount name="SOME COMPANY ACCOUNT" number="11111111" sortCode="11-11-11" type="0" bankName="BANK" branchName="SOME TOWN" /"
"ReturnedDebitItem ref="121212TEST1" transCode="17" returnCode="1363" returnDescription="INSTRUCTION CANCELLED" originalProcessingDate="2017-12-29" valueOf="60.00" currency="GBP""
"PayerAccount number="12345678" ref="121212TEST1" name="JOHN" sortCode="12-34-56" /"
"/ReturnedDebitItem"
"ReturnedDebitItem ref="121212TEST2" transCode="17" returnCode="5363" returnDescription="NO ACCOUNT" originalProcessingDate="2017-12-29" valueOf="60.00" currency="GBP""
"PayerAccount number="87654321" ref="121212TEST2" name="PAUL" sortCode="09-09-09" /"
"/ReturnedDebitItem"
"ReturnedDebitItem ref="121212TEST3" transCode="17" returnCode="1363" returnDescription="INSTRUCTION CANCELLED" originalProcessingDate="2017-12-29" valueOf="60.00" currency="GBP""
"PayerAccount number="33333333" ref="121212TEST3" name="MARY" sortCode="33-33-33" /"
"/ReturnedDebitItem"
"/OriginatingAccountRecord"
"/OriginatingAccountRecords"
"/Advice"
"/ARUDD"
"/Data"
"/BACSDocument"