|
-
Jun 27th, 2005, 12:30 PM
#1
Thread Starter
Junior Member
Remove a XML Node list
Hi All, I have a XML file in wich i have a node list of about 1000 node. I want to remove this list. For now i'm cycling through all the node one by one and i call the removechild property like this:
VB Code:
Set noLiblRaprts = pobjNewNodeRacine.selectNodes("LiblRaprt")
For Each noLiblRaprt In noLiblRaprts
Call pobjNewNodeRacine.removeChild(noLiblRaprt)
Next
The problem is that it's slow. There is 1000 node and about 100,000 XML file to process! Is there any other way to remove a node list in one command??? I can't change the way the XML file are built...
Thanks for your help!
Last edited by bthibault76; Jun 27th, 2005 at 12:35 PM.
-
Jun 28th, 2005, 03:31 AM
#2
Re: Remove a XML Node list
'fraid not. The DOM provides no means to remove nodes other than removeChild.
However, you might want to experiment with DocumentFragment. Using that, it should in theory be possible to remove many nodes at once. (Depending on the implementation, though, there's no guarantee that this doesn't take just as long, though.) The downside is that you first have to create the DocumentFragment, which might take just as long as deleting the nodes one by one.
What's selectNodes anyway? It's not a DOM method. Perhaps your DOM has another non-standard method called addAll(NodeList)? That would be useful.
For large XML files, you might want to look into completely different ways of processing the XML. Or perhaps you could build the DOM tree yourself using a SAX processor, filtering the undesired elements out at this level.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|