Parse XML with JRuby (Hpricot?) with tags like <foo.bar>

我怕爱的太早我们不能终老 提交于 2019-12-13 15:11:29

问题


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:


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



来源:https://stackoverflow.com/questions/1396511/parse-xml-with-jruby-hpricot-with-tags-like-foo-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!