Clemens Wyss asked: > is there (besides the SAX) a DOM implementaion available, which > allows adding/removing elements and writing the DOM-tree? Well, XMLParser http://www.ruby-lang.org/en/raa-list.rhtml?name=XMLParser does have a file xmltree.rb in it's lib directory. I strongly suspect you can use it's classes in a DOM way (I've never really used DOM, so can't say if this is fully compliant). Here's an example, inserting a xpointer after each element: - Aleksi require 'xmltreebuilder' def annotateWithXPointer(node, recursively = false) if recursively node.childNodes do |child| if child.type == XML::Element annotateWithXPointer(child, recursively) end end end xpointer = node.makeXPointer(false) annotate = XML::Element.new("xpointer", nil, [XML::Text.new(xpointer)]) node.insertBefore(annotate, node[0]) end builder = XML::SimpleTreeBuilder.new xml = STDIN.read begin tree = builder.parse(xml) rescue XMLParserError => xpe line = builder.line print "#{$0}: #{xpe} in line #{line}\n" exit 1 end root = tree.documentElement annotateWithXPointer(root, true) puts tree.to_s Given this input <?xml version="1.0"?> <news> <title> Ruby Mine opens </title> <info> <submitter>Aleksi Niemela</submitter> <email>Aleksi.Niemela / ale.cx</email> <datetime>2000-11-11 02:45</datetime> </info> <body> <p> Just when the discussion sprouted on Ruby-talk I manage to finally open my site dedicated to Ruby and related biz and buzz. </p> <p> Even though there has been no public announcement yet, the site is fully accessible. Everything is still heavily under construction, so don't be surprised if something doesn't work. Let me know, while we probably are already working on it. </p> </body> </news> it outputs <news><xpointer>root()</xpointer> <title><xpointer>root().child(1,title)</xpointer> Ruby Mine opens </title> <info><xpointer>root().child(1,info)</xpointer> <submitter><xpointer>root().child(1,info).child(1,submitter) </xpointer>Aleksi Niemela</submitter> <email><xpointer>root().child(1,info).child(1,email)</xpointer> Aleksi.Niemela / ale.cx</email> <datetime><xpointer>root().child(1,info).child(1,datetime) </xpointer>2000-11-11 02:45</datetime> </info> <body><xpointer>root().child(1,body)</xpointer> <p><xpointer>root().child(1,body).child(1,p)</xpointer> Just when the discussion sprouted on Ruby-talk I manage to finally open my site dedicated to Ruby and related biz and buzz. </p> <p><xpointer>root().child(1,body).child(2,p)</xpointer> Even though there has been no public announcement yet, the site is fully accessible. Everything is still heavily under construction, so don't be surprised if something doesn't work. Let me know, while we probably are already working on it. </p> </body> </news>