Delete sections according to their ID
Hi All,
I need to get help again since I got a difficult problem which I spend so much time and canât solve it by myself. I try to compare two Segments, and if their IDs match, then delete the sections. The following is the original XML file. I need to compare the CBAPartyâs relatedID with Partyâs uniqueID. If their IDs match each other, then delete the corresponding CBAParty section.
<CBAEnvelope>
<CBAPartySegment>
<CBAParty>
<RelatedEntityRef RelatedID="P1"/>
<Shortname>Mr J M Jones</Shortname>
</CBAParty>
<CBAParty>
<RelatedEntityRef RelatedID="P2"/>
<Shortname>Mr D Smiles</Shortname>
</CBAParty>
<CBAParty>
<RelatedEntityRef RelatedID="P3"/>
<Shortname>Mr M Brown</Shortname>
</CBAParty>
<CBAParty>
<RelatedEntityRef RelatedID="P4"/>
<Shortname>Mrs L Brown</Shortname>
</CBAParty>
</CBAPartySegment>
<Application>
<PartySegment>
<Party>
<Identifier UniqueID="P1"/>
</Party>
<Party>
<Identifier UniqueID="P2"/>
</Party>
</PartySegment>
</Application>
</CBAEnvelope>
The following is supposed to be the outcome. The two CBAPartys with relatedID âP1â and âP2â have been deleted since these two IDs can be found in Party sections.
<CBAEnvelope>
<CBAPartySegment>
<CBAParty>
<RelatedEntityRef RelatedID="P3"/>
<Shortname>Mr D Smiles</Shortname>
</CBAParty>
<CBAParty>
<RelatedEntityRef RelatedID="P4"/>
<Shortname>Mrs L Brown</Shortname>
</CBAParty>
</CBAPartySegment>
<Application>
<PartySegment>
<Party>
<Identifier UniqueID="P1"/>
</Party>
<Party>
<Identifier UniqueID="P2"/>
</Party>
</PartySegment>
</Application>
</CBAEnvelope>
Many thanks if anyone could give me some suggestion or example. Thanks for everyoneâs time as well.
Kind Regards,
Ken
|