Removing XML elements based on attribute value using XSLT



I couldn't find a solution for my problem here, So please help me to find a way to filter elements of XML document based on value of attributes.


Clearly, for a document like this:



<records>
<record>
<Rec1>Guy Levy</Rec1>
<Rec2 Type="1">72910589</Rec2>
<Rec3 Type="2">some content</Rec3>
<Rec4 Type="3">some content</Rec4>
<Rec5 Type="4">some content</Rec5>
<Rec6 Type="5">some content</Rec6>
<Rec7 Type="6">some content</Rec7>
</record>
<record>
<Rec1>Bruno Vang</Rec1>
<Rec2 Type="1">some content</Rec2>
<Rec3 Type="2">some content</Rec3>
<Rec4 Type="3">some content</Rec4>
<Rec5 Type="4">some content</Rec5>
<Rec6 Type="5">some content</Rec6>
<Rec7 Type="6">some content</Rec7>
</record>
</records>


I want to have elements with , for example, attributes Type="1" and Type="3":



<records>
<record>
<Rec1>Guy Levy</Rec1>
<Rec2 Type="1">72910589</Rec2>
<Rec4 Type="3">some content</Rec4>
</record>
<record>
<Rec1>Bruno Vang</Rec1>
<Rec2 Type="1">some content</Rec2>
<Rec4 Type="3">some content</Rec4>
</record>
</records>


Thanks for help!


No comments:

Post a Comment