From transfire at gmail.com Mon Aug 14 10:24:22 2006 From: transfire at gmail.com (TRANS) Date: Mon, 14 Aug 2006 10:24:22 -0400 Subject: [libxml-devel] How to insert before, after and prepend, plus speed issue Message-ID: <4b6f054f0608140724i4f24c234v78f39bf31f81b309@mail.gmail.com> Hi-- 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? 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. 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? Thanks, T. From rosco at roscopeco.co.uk Tue Aug 15 07:33:38 2006 From: rosco at roscopeco.co.uk (Ross Bamford) Date: Tue, 15 Aug 2006 12:33:38 +0100 Subject: [libxml-devel] How to insert before, after and prepend, plus speed issue In-Reply-To: <4b6f054f0608140724i4f24c234v78f39bf31f81b309@mail.gmail.com> References: <4b6f054f0608140724i4f24c234v78f39bf31f81b309@mail.gmail.com> Message-ID: Hi Trans, On Mon, 14 Aug 2006 15:24:22 +0100, TRANS 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('').parse # => bar = xd.root.child # => bar.prev = XML::Node.new('boo') # => bar.next = XML::Node.new('too') # => xd # => > 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 - rosco at roscopeco.co.uk From rosco at roscopeco.co.uk Tue Aug 15 08:22:49 2006 From: rosco at roscopeco.co.uk (Ross Bamford) Date: Tue, 15 Aug 2006 13:22:49 +0100 Subject: [libxml-devel] Request to add HTML parsing In-Reply-To: <44BC3A9A.6070809@thomaszone.com> References: <44BC3A9A.6070809@thomaszone.com> Message-ID: Hi Mark, On Tue, 18 Jul 2006 02:34:18 +0100, Mark Thomas wrote: > I'm switching to Ruby from Perl, and currently I do all my HTML parsing > in > perl's XML::LibXML. Applying XPath to parse HTML is extremely powerful > and > fast, fast, fast in libxml. > > Can you add that feature to the Ruby one? I think it would be easy to do; > it's just a flag on the parser, which tells libxml to create a DOM from > HTML instead of XML, and all the XML methods then magically work on the > HTML! > Sure, I'll look into this for 0.4.0. Cheers, -- Ross Bamford - rosco at roscopeco.co.uk From rosco at roscopeco.co.uk Tue Aug 15 08:33:56 2006 From: rosco at roscopeco.co.uk (Ross Bamford) Date: Tue, 15 Aug 2006 13:33:56 +0100 Subject: [libxml-devel] minor typo in README file example In-Reply-To: <11a866cb0606151154w29eeb17bj9a0049af6288c160@mail.gmail.com> References: <11a866cb0606151154w29eeb17bj9a0049af6288c160@mail.gmail.com> Message-ID: Hi, On Thu, 15 Jun 2006 19:54:28 +0100, Aitor Garay-Romero wrote: > In the README file the "reading xml" example is not correct. > Somewhere > it says: > > puts "Node path: #{node.path} \t Contents: #{node}" > > But it should say: > > puts "Node path: #{node.path} \t Contents: #{node.contents}" > > If not the output will not be the one shown on the page. > Thanks for that, I've fixed it and will commit as soon as a small CVS hiccup is resolved. -- Ross Bamford - rosco at roscopeco.co.uk From rosco at roscopeco.co.uk Tue Aug 15 08:37:19 2006 From: rosco at roscopeco.co.uk (Ross Bamford) Date: Tue, 15 Aug 2006 13:37:19 +0100 Subject: [libxml-devel] Segfault when doing simple parsing In-Reply-To: <62e8012c0606270614n4d6e7b1ao3c3cdac35a4b9a90@mail.gmail.com> References: <62e8012c0606270614n4d6e7b1ao3c3cdac35a4b9a90@mail.gmail.com> Message-ID: On Tue, 27 Jun 2006 14:14:05 +0100, Pedro C?rte-Real wrote: > I'm trying to use libxml to run some XPath on a document I have as a > string in memory. This is my code for parsing the document: > > parser = XML::Parser.new > parser.string = self.content > @xmldoc = parser.parse > > Doing the same thing in a test script seems to work without > segfaulting. This is run inside a rails model and segfaults when > testing it. Here's the backtrace: > > 0xb72b37c4 in ruby_xml_parser_parse (self=144875496) at > ruby_xml_parser.c:1124 > 1124 xmlFreeDoc(rxpc->ctxt->myDoc); > > #0 0xb72b37c4 in ruby_xml_parser_parse (self=144875496) > at ruby_xml_parser.c:1124 > #1 0xb7ef050b in rb_iterator_p () from /usr/lib/libruby1.8.so.1.8 > #2 0xb7efaf8c in rb_thread_trap_eval () from /usr/lib/libruby1.8.so.1.8 > (...) > We have a few memory handling bugs that are still being ironed out, so it's possible you're seeing one of those. Hopefully soon we'll be able to release a fixed up version, but in the meantime you may (or may not) get more joy from the current CVS version. I'll try to reproduce this and take a look at it. Thanks, -- Ross Bamford - rosco at roscopeco.co.uk From steve at asklater.com Fri Aug 18 13:50:34 2006 From: steve at asklater.com (SteveC) Date: Fri, 18 Aug 2006 18:50:34 +0100 Subject: [libxml-devel] reading from a String? Message-ID: <20060818175034.GA29102@asklater.com> The Document api lists new(version) and file(filename): http://libxml.rubyforge.org/doc/classes/XML/Document.html I'd like to create a document from an xml file already in a string a-la REXML::Document.new Is there some other magic way of doing that? have fun, SteveC steve at asklater.com http://www.asklater.com/steve/ From grant at janrain.com Fri Aug 18 13:53:46 2006 From: grant at janrain.com (Grant Monroe) Date: Fri, 18 Aug 2006 10:53:46 -0700 Subject: [libxml-devel] reading from a String? In-Reply-To: <20060818175034.GA29102@asklater.com> References: <20060818175034.GA29102@asklater.com> Message-ID: <826ff8bf0608181053u5881531ev3b2fe417625d2ad0@mail.gmail.com> p = XML::Parser.new p.string = yourstring doc = p.parse On 8/18/06, SteveC wrote: > The Document api lists new(version) and file(filename): > > http://libxml.rubyforge.org/doc/classes/XML/Document.html > > I'd like to create a document from an xml file already in a string a-la > REXML::Document.new > > Is there some other magic way of doing that? > > have fun, > > SteveC steve at asklater.com http://www.asklater.com/steve/ > _______________________________________________ > libxml-devel mailing list > libxml-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/libxml-devel > > -- Grant Monroe JanRain, Inc. From mvette13 at gmail.com Fri Aug 18 13:56:27 2006 From: mvette13 at gmail.com (Mark Van Holstyn) Date: Fri, 18 Aug 2006 13:56:27 -0400 Subject: [libxml-devel] reading from a String? In-Reply-To: <826ff8bf0608181053u5881531ev3b2fe417625d2ad0@mail.gmail.com> References: <20060818175034.GA29102@asklater.com> <826ff8bf0608181053u5881531ev3b2fe417625d2ad0@mail.gmail.com> Message-ID: doc = XML::Parser.string( "...data..." ).parse On 8/18/06, Grant Monroe wrote: > > p = XML::Parser.new > p.string = yourstring > doc = p.parse > > > On 8/18/06, SteveC wrote: > > The Document api lists new(version) and file(filename): > > > > http://libxml.rubyforge.org/doc/classes/XML/Document.html > > > > I'd like to create a document from an xml file already in a string a-la > > REXML::Document.new > > > > Is there some other magic way of doing that? > > > > have fun, > > > > SteveC steve at asklater.com http://www.asklater.com/steve/ > > _______________________________________________ > > libxml-devel mailing list > > libxml-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/libxml-devel > > > > > > > -- > Grant Monroe > JanRain, Inc. > _______________________________________________ > libxml-devel mailing list > libxml-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/libxml-devel > -- Mark Van Holstyn mvette13 at gmail.com http://lotswholetime.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/libxml-devel/attachments/20060818/c49ff910/attachment-0001.html From steve at asklater.com Fri Aug 18 14:03:16 2006 From: steve at asklater.com (SteveC) Date: Fri, 18 Aug 2006 19:03:16 +0100 Subject: [libxml-devel] reading from a String? In-Reply-To: <826ff8bf0608181053u5881531ev3b2fe417625d2ad0@mail.gmail.com> References: <20060818175034.GA29102@asklater.com> <826ff8bf0608181053u5881531ev3b2fe417625d2ad0@mail.gmail.com> Message-ID: <20060818180316.GB29102@asklater.com> Brilliant, thanks for the super quick response. Can I suggest that this snippet be put in the Reading example? Here's a little patch to the README 140,148d139 < If you want to parse a xml document already in a string, you can < extract it with < < p = XML::Parser.new < p.string = yourstring < doc = p.parse < < and then use doc as in the above example. < * @ 18/08/06 06:53:46 PM grant at janrain.com wrote: > p = XML::Parser.new > p.string = yourstring > doc = p.parse > > > On 8/18/06, SteveC wrote: > >The Document api lists new(version) and file(filename): > > > >http://libxml.rubyforge.org/doc/classes/XML/Document.html > > > >I'd like to create a document from an xml file already in a string a-la > >REXML::Document.new > > > >Is there some other magic way of doing that? > > > >have fun, > > > >SteveC steve at asklater.com http://www.asklater.com/steve/ > >_______________________________________________ > >libxml-devel mailing list > >libxml-devel at rubyforge.org > >http://rubyforge.org/mailman/listinfo/libxml-devel > > > > > > > -- > Grant Monroe > JanRain, Inc. have fun, SteveC steve at asklater.com http://www.asklater.com/steve/ From shimbo at is.naist.jp Sat Aug 19 11:14:28 2006 From: shimbo at is.naist.jp (Masashi Shimbo) Date: Sun, 20 Aug 2006 00:14:28 +0900 Subject: [libxml-devel] [PATCH] libxml-ruby gem fails to build Message-ID: <87lkpk3gh7.wl%shimbo@is.naist.jp> Hi, I tried to install libxml-ruby 0.3.8 gem on my Ubuntu Linux box without success. The installation apparently succeeded with no errors, but 'gem check -t libxml-ruby' fails with the message /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- xml/libxml_so (LoadError) It seems that RubyGem expects the source directory for extensions to be different from where they are installed (typically 'lib/'), but the current libxml-ruby gem uses 'ext/' for both. Consequently, the following happens with 'gem install'; Note that 'gem install' runs 'extconf.rb' in 'ext/xml/' and then 'make; make install; make clean': 1. The file 'ext/xml/libxml_so.so' compiles fine. 2. Because RUBYARCHDIR is 'ext/xml/', 'make install' does nothing. # N.B. gem overwrites RUBYLIBDIR and RUBYARCHDIR to the value of # 'require_path' field in the gem spec just before 'make' is run. 3. gem finally runs 'make clean' and 'ext/xml/libxml_so.so' is removed. Attached is a patch that fixes the problem. It essentially - creates 'lib/xml' directory; - sets the gem spec 'require_path' field to 'lib/xml' (in place of 'ext/xml'); - moves 'ext/xml/libxml.rb' to 'lib/xml' directory; and - installs libxml_so.so in 'lib/xml' upon 'gem install'. My environment is: Ubuntu Linux 6.06 / RubyGem 0.9.0 / Ruby 1.8.4 Masashi Shimbo -------------- next part -------------- A non-text attachment was scrubbed... Name: libxml-ruby-0.3.8.diff Type: application/octet-stream Size: 5798 bytes Desc: not available Url : http://rubyforge.org/pipermail/libxml-devel/attachments/20060820/581a5aae/attachment.obj From luc_van_deuren at yahoo.com Tue Aug 29 21:27:02 2006 From: luc_van_deuren at yahoo.com (Luc Van Deuren) Date: Tue, 29 Aug 2006 18:27:02 -0700 (PDT) Subject: [libxml-devel] cdata comment patch Message-ID: <20060830012702.92362.qmail@web32410.mail.mud.yahoo.com> Hello, I just needed #CDATA and comment into my xml output. making a cdata or comment node did not seem to work, so i made a quick patch, (cdata_comment_patch.zip) ruby_xml_node.c node = XML::Node.new_cdata("mycdata") will create a #CDATA node "" node << "_add_to_it" will just add to the data. " node = XML::Node.new_comment("mycomment") will create a comment node "" node << "_add_to_it" will just add to the comment. " + two testfiles tests/tc_xml_node7 tests/tc_xml_node8 for testing both Question: does the XML::Node.new_cdata and XML::Node.new_comment seems a good idea? or is there a more sofisticated solution? btw, i'm happy this libxml-ruby exists, thanks for the effort! Luc, --------------------------------- Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/libxml-devel/attachments/20060829/7505291a/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: cdata_comment_patch.zip Type: application/zip Size: 2069 bytes Desc: 1810481609-cdata_comment_patch.zip Url : http://rubyforge.org/pipermail/libxml-devel/attachments/20060829/7505291a/attachment.zip