views:

416

answers:

1

I'm trying to consume some legacy XML with elements like this in JRuby:

<x-doc attr="value">
  <nested>
    <with.dot>content</with.dot >
  </nested>
</x-doc>

I've been working with Hpricot, but Hpricot's HTML-oriented shortcuts are working against me: doc.search("//with.dot") seems to be looking for <with class="dot" />

(I ran into this problem with JQuery too, a few years ago.)

Can I do this with Hpricot, or do I need to use a different library?

+1  A: 

Check out nokogiri. It's said to be "A Faster, Better HTML and XML Parser for Ruby (than Hpricot)".

jamesaharvey
Thanks -- it's great to see that doc.search("//with.dot") works properly in Nokogiri. Sadly, it doesn't work on my target platform, which doesn't have any -dev packages (nor even a compiler) installed.
Ed Brannin
It now seems as if Nokogiri is working on Jruby: http://stackoverflow.com/questions/1811864/possible-to-load-nokogiri-in-jruby-without-installing-nokogiri-java and http://stackoverflow.com/questions/1448512/how-to-use-nokogiri-from-jruby-on-windows
i5m