Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help me to find a way to filter elements of XML document based on value of attributes.

Clearly, for a document like this:
XML
<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":

XML
<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
Posted
Comments
_Asif_ 9-Feb-15 3:28am    
What have you tried?
John C Rayan 19-Feb-15 11:00am    
you have to specify where you want to do this. Linq/XSLT/XQuery etc...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900