Results 1 to 2 of 2

Thread: Remove a XML Node list

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2003
    Posts
    21

    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:
    1. Set noLiblRaprts = pobjNewNodeRacine.selectNodes("LiblRaprt")
    2.     For Each noLiblRaprt In noLiblRaprts
    3.         Call pobjNewNodeRacine.removeChild(noLiblRaprt)
    4.     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.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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
  •  



Click Here to Expand Forum to Full Width