libxml-ruby

Ruby: Can't save document with Libxml-ruby

From the libxml-ruby API docs (http://libxml.rubyforge.org/rdoc/index.html), under LibXML::XML::Document, I tried the following: filename = 'something.xml' stats_doc = XML::Document.new() stats_doc.root = XML::Node.new('root_node') stats_doc.root << XML::Node.new('elem1') stats_doc.save(filename, :indent => true, :encoding => 'utf-8') ...

Ruby: libxml-ruby and adding nicely-formatted sibling nodes

Given my existing XML (test.xml): <root> <element> <child id="1" /> <child id="2" /> <child id="3" /> </element> </root> And my ruby code: require 'rubygems' require 'xml' parser = XML::Parser.file("test.xml") doc = parser.parse target = doc.find('/*/element') target << child = XML::Node.new('child') child['id'] = '...

libxml-ruby on windows xp problem

About a month ago I installed libxml-ruby using gem install libxml-ruby and it worked fine. Then i went to install it on another machine today and it failed with this error: C:\Windows\system32>gem install -r libxml-ruby Building native extensions. This could take a while... ERROR: Error installing libxml-ruby: ERROR: Failed ...

How do I tell libxml-ruby about external entity files?

I'm trying to validate using libxml-ruby's DTD#validate, but I keep getting the following warnings: Warning: failed to load external entity "xhtml-lat1.ent" at :29. Warning: failed to load external entity "xhtml-symbol.ent" at :34. Warning: failed to load external entity "xhtml-special.ent" at :39. I wouldn't mind, except I use things...

Convert a Nokogiri document to a Ruby Hash

Is there an easy way to convert a Nokogiri XML document to a Hash? Something like Rails' Hash.from_xml. ...

libxml-ruby parsing HELP...

Alright, switching from working Hpricot to Libxml-ruby due to speed and well the disappearance of _why, looked at Nokogiri for a second but decided to look at Libxml-ruby for speed and longevity. I must be missing something basic but what im trying to do isn't working, here's my XML string file =<<XML <?xml version="1.0" encoding="utf-8...

Clear Unwanted Namespaces with LibXML-Ruby

I would like to parse an Atom Feed and create an Atom-compliant cache of each Entry. The problem is that some feeds (this one for example) have many namespaces other than the Atom one. Is it possible to keep intact all Atom nodes and remove each node that belongs to another namespace? Something like this: valid_nodes = entry.find('a...

libxml-ruby and multiple namespaces

having this xml declaration: <didl:DIDL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:didl="urn:mpeg:mpeg21:2002:02-DIDL-NS" xsi:schemaLocation="urn:mpeg:mpeg21:2002:02-DIDL-NS http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-21_schema_files/did/didmodel.xsd"&gt; what is the way to defin...

How can I stop parse when find the 1st element ?

I would like to stop parse when find 1st element even there is more same element after that. I use libxml,SAX on ruby. This code show every <usr> element. But I want to stop parse when find 1st <usr>. Because this XML file will be huge. Does anybody know how stop to parse when find 1st element by SAX method. code #! ruby -Ku require...

Parsing namespaced XML using libxml-ruby

I'm attempting to parse XML in the following format (from the European Central Bank data feed) using libxml-ruby: <?xml version="1.0" encoding="UTF-8"?> <gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"&gt; <gesmes:subject>Reference rates</...

Processing large XML file with libxml-ruby chunk by chunk

I'd like to read a large XML file that contains over a million small bibliographic records (like <article>...</article>) using libxml in Ruby. I have tried the Reader class in combination with the expand method to read record by record but I am not sure this is the right approach since my code eats up memory. Hence, I'm looking for a rec...

Libxml Ruby : Do I need to manually garbage collect node sets returned by doucment#find?

The documentation for LibXML::XML::Document#find mentions that following code style needs to be used to avoid seg faults: nodes = doc.find('/header') nodes.each do |node| ... do stuff ... end Is this all I need to do? Below the example code box there is some commented out code: # nodes = nil # GC.start Do I need to include this c...

libxml-ruby failed to load at x86_64

We are having problem with libxml-ruby gem at the server side Possible because it uses x86_64 architecture: $ uname -a Linux ip-10-228-171-64 2.6.21.7-2.fc8xen-ec2-v1.0 #1 SMP Tue Sep 1 10:25:30 EDT 2009 x86_64 GNU/Linux require 'libxml' LoadError: /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.4/lib/libxml_ruby.so: ...

[BUG] Bus Error - What causes this in Ruby?

I have run into this error 5 or 10 times over the past few years and have never found a clear answer to this problem. Here is the error: $ rake db:migrate /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.5/lib/libxml_ruby.bundle: [BUG] Bus Error ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0] Abort trap The app I am running thi...

XML schema validation and pattern errors

I have a problem validating a perfectly valid XML with it's schema file in Ruby. It works OK on my development machine (OS X 10.6) but fails everytime on the production system (Debian 4.1). The part of the XML that gives errors is this: <ROUNDINGS>-0.02</ROUNDINGS> And the XSD pattern is this: <xsd:element name="ROUNDINGS"> <xsd:s...

Problem installing LibCurl + LibXML + FeedZirra on Windows XP.

Hi, I am rails newbie. I am working on Windows XP. I have this version of ruby. ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32] I have Rails 2.3.8 installed. I am trying to install feedzirra trying every possible way after watching the Rails Cast 168. First I tried to install using gem install pauldix-feedzirra. I got this ...