Home All Groups Group Topic Archive Search About

XML Filter Fast Way?

Author
6 Nov 2006 5:12 AM
xeroxero
I have an XML document that I would like to remove/filter whole nodes
(and their child nodes) if an attribute is not contained/matched. I
would like to output a new XML document, not modifying the original.
Can anyone recommend XSLT for this or a programmatic way if it's
faster?


<item look="a;b">
    <item look="a;b">
        <subitem/>
        <subitem/>
        <item look="a">
            <subitem/>
            </subitem/>
        </item>
    </item>
<item>

I would like to apply an expression to the above document, so any
<item> element that does not have a "b" in the look attribute is
removed. I would like the result XML document to be:

<item look="a;b">
    <item look="a;b">
        <subitem/>
        <subitem/>
    </item>
<item>


Thanks.

Author
6 Nov 2006 11:19 AM
Mubashir Khan
i guess you can use xpath queries ....
Show quote
"xeroxero" <xeroxero@newsgroups.nospam > wrote in message
news:i1htk2lqh5gga4dcpnm7virlnrb9lb88vc@4ax.com...
>
>
> I have an XML document that I would like to remove/filter whole nodes
> (and their child nodes) if an attribute is not contained/matched. I
> would like to output a new XML document, not modifying the original.
> Can anyone recommend XSLT for this or a programmatic way if it's
> faster?
>
>
> <item look="a;b">
> <item look="a;b">
> <subitem/>
> <subitem/>
> <item look="a">
> <subitem/>
> </subitem/>
> </item>
> </item>
> <item>
>
> I would like to apply an expression to the above document, so any
> <item> element that does not have a "b" in the look attribute is
> removed. I would like the result XML document to be:
>
> <item look="a;b">
> <item look="a;b">
> <subitem/>
> <subitem/>
> </item>
> <item>
>
>
> Thanks.
>
>
>
>
>
>
>
>
>
>
>
>
>
Author
6 Nov 2006 4:44 PM
xeroxero
That is not going to work. The original XML document is generated
dynamically. I think I need to do XSLT or some kind of
iterative/dynamic XPath technology. Can anyone provide a sample?




Show quote
On Mon, 6 Nov 2006 05:19:01 -0600, "Mubashir Khan" <m***@yahoo.com>
wrote:

>i guess you can use xpath queries ....
>"xeroxero" <xeroxero@newsgroups.nospam > wrote in message
>news:i1htk2lqh5gga4dcpnm7virlnrb9lb88vc@4ax.com...
>>
>>
>> I have an XML document that I would like to remove/filter whole nodes
>> (and their child nodes) if an attribute is not contained/matched. I
>> would like to output a new XML document, not modifying the original.
>> Can anyone recommend XSLT for this or a programmatic way if it's
>> faster?
>>
>>
>> <item look="a;b">
>> <item look="a;b">
>> <subitem/>
>> <subitem/>
>> <item look="a">
>> <subitem/>
>> </subitem/>
>> </item>
>> </item>
>> <item>
>>
>> I would like to apply an expression to the above document, so any
>> <item> element that does not have a "b" in the look attribute is
>> removed. I would like the result XML document to be:
>>
>> <item look="a;b">
>> <item look="a;b">
>> <subitem/>
>> <subitem/>
>> </item>
>> <item>
>>
>>
>> Thanks.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>

AddThis Social Bookmark Button