From: Its Me Date: 2004-04-22T06:34:09+09:00 Subject: rexml - extreme speed issue I am having extreme speed issues with some simple rexml code and want to know if I am doing something findamentally wrong. The source xml document has a few thousand elements, attributes are not used much, text nodes are present. I need to do some surgery on the tree, walking sequentially through the initial very flat tree and moving things into a 3-level structure based on known target levels for the element types. Just takes a single pass, and does include some delete_element and add_element calls.The main method is: @doc = REXML::Document.new @infile target_level_0_nodes = ["A", "B", "C"] target_level_1_nodes = ["a", "b", "c"] target_level_2_nodes = ["x","y", "z"] def relocate_siblings () root = @doc.root level_0 = nil level_1 = nil level_2 = nil root.each_element do |curr| p curr if target_level_0_nodes.include? curr.name level_0 = curr else if target_level_1_nodes.include? curr.name curr.parent.delete_element(curr) level_0.add_element(curr) level_1 = curr else curr.parent.delete_element(curr) level_1.add_element(curr) level_2 = curr end end end end This runs excruciatingly slowly, literally taking seconds between printing nodes. I could edit the tree in XMLSpy just marginally slower. The disk is not awfully busy, CPU is at right about 100%. Help!! What am I doing wrong? I do not want to have to deal with XSLT!