使用< foo.bar> [英] Parse XML with JRuby (Hpricot?) with tags like <foo.bar>

查看:105
本文介绍了使用< foo.bar>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在JRuby中使用一些具有此类元素的旧XML:

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>

我一直在使用Hpricot,但是Hpricot的面向HTML的快捷方式对我不利:doc.search("//with.dot")似乎正在寻找<with class="dot" />

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" />

(几年前,我在JQuery中也遇到了这个问题.)

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

我可以使用Hpricot做到这一点,还是需要使用其他库?

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

推荐答案

查看 nokogiri .据说它是比Ruby更快,更好的Ruby HTML和XML解析器(比Hpricot)".

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

这篇关于使用&lt; foo.bar&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆