vb.net - Fast processing of large XML file -


i have big xmlnode in vb.net (we're talking 10s/100s of thousands of nodes, , millions of attributes).

the general structure of xml is:

<other xml nodes></other xml nodes> <list>     <item attr1="" attr2="" attr3="" attr4="" ... />     <item attr1="" attr2="" attr3="" attr4="" ... />     <item attr1="" attr2="" attr3="" attr4="" ... />     <item attr1="" attr2="" attr3="" attr4="" ... />     <item attr1="" attr2="" attr3="" attr4="" ... />     <item attr1="" attr2="" attr3="" attr4="" ... />     .     .     . </list> 

what want do, remove item nodes based upon attributes (say if had 50,000 nodes, criteria delete 49500 of them).

the problem have, takes few seconds code remove such large number of nodes, , need go faster.

i've tried few different ways of doing this, fastest i've got todate is:

dim xnllist = xnbigxmlnode.selectnodes("//list/item[@attr1=sample]") each xnnode in xnllist     xnnode.parentnode.removechild(xnnode) next 

*please forgive mistakes in above code, i'm not @ development machine @ moment

as added constraint, need keep "other xml nodes" in xmlnode.

i've considered deleting whole list, , adding nodes needed, took longer execute.

can think of way deleting thousands of nodes faster?

thanks in advance

looks classic case writing sax filter. parser generates sax events , passes them application, application passes subset of events on serializer, generates new xml file. no need build tree in memory.

i don't know details of how in vb, being java man, technology exists.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -