Hi Trans, On Mon, 14 Aug 2006 15:24:22 +0100, TRANS <[EMAIL PROTECTED]> wrote:
> I'm trying to figuere out how to add a node before and after another > node. I think for after I use sibling, but I have no ida about before. > > Also I need to prepend a node to the inner xml of a node as opposed to > add it to the end. how is that done? > I don't know of a way with the latest release, but if you don't mind using CVS head you get handy prev= and next= methods on XML::Node, e.g: XML::Parser::VERSION # => "0.3.9" xd = XML::Parser.string('<foo><bar/><baz/></foo>').parse # => <?xml version="1.0"?> <foo> <bar/> <baz/> </foo> bar = xd.root.child # => <bar/> bar.prev = XML::Node.new('boo') # => <boo/> bar.next = XML::Node.new('too') # => <too/> xd # => <?xml version="1.0"?> <foo> <boo/> <bar/> <too/> <baz/> </foo> > FYI, if interested I've been working on a lib called Cherry XML that > creates a nice interface much like Hpricot's, but instead uses > adapters for either REXML or ruby-libxml. > Sounds cool, is it online yet? > I'm looking foward to using libxml primarily but there's still some > issues with the lib, so I have to fall back to REXML. The most > signifficant thing I've noticed it that I'm getting execution times 5 > times slower than REXML. That mkes no sense. Has anyone else seen > this? > Hmm, are you using the SAX parser? My first implementation is painfully slow, I underestimated the overhead of proc callbacks. Since 0.4.0 is up next, I'm thinking of breaking the API (it's new anyway) and replacing the Sax parser with a method-based one... My prototype is a bit faster than the current one, and I'm still working on it. If it's not that, I'd appreciate if you'd send over your benchmarks and I'll see if I can figure it out. Cheers, -- Ross Bamford - [EMAIL PROTECTED] _______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel