标签: libxml-ruby

将Nokogiri文档转换为Ruby Hash

有没有一种简单的方法将Nokogiri XML文档转换为Hash?

像Rails这样的东西Hash.from_xml.

ruby xml hash nokogiri libxml-ruby

67
推荐指数
6
解决办法
4万
查看次数

libxml-ruby:无法构建gem原生扩展

我正在尝试安装libxml-ruby.我安装了libxml2,libxsltcoreutils

我还阅读了有关该问题的其他帖子,但没有一个解决它.

brew list libxslt

/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/bin/xslt-config
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/bin/xsltproc
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/include/libexslt/ (3 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/include/libxslt/ (21 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/libexslt.0.dylib
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/libxslt.1.dylib
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/pkgconfig/ (2 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/ (5 other files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/share/aclocal/libxslt.m4
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/share/doc/ (90 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/share/man/ (3 files)
Run Code Online (Sandbox Code Playgroud)

brew list libxml2

/opt/boxen/homebrew/Cellar/libxml2/2.9.4/bin/xml2-config
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/bin/xmlcatalog
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/bin/xmllint
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/include/libxml2/ (47 files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/libxml2.2.dylib
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/cmake/libxml2/libxml2-config.cmake
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/pkgconfig/libxml-2.0.pc
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/ (3 other files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/aclocal/libxml.m4
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/doc/ (153 files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/gtk-doc/ (55 files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/man/ (4 files)
Run Code Online (Sandbox Code Playgroud)

gem install libxml-ruby 产生以下错误:

Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
    ERROR: Failed …
Run Code Online (Sandbox Code Playgroud)

macos homebrew rubygems libxml2 libxml-ruby

12
推荐指数
5
解决办法
5808
查看次数

无法为rails 2.3.14安装libxml-ruby

执行'bundle install'时出现此错误:

..........

Installing libxml-ruby (2.7.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /home/ubuntu/.rvm/rubies/ruby-1.8.7-p374/bin/ruby extconf.rb 
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... yes
checking for atan() in -lm... no
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -llibiconv... no
checking for iconv_open() in -llibiconv... no
checking for iconv_open() in -lc... yes
checking for xmlParseDoc() in …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails libxml-ruby

7
推荐指数
2
解决办法
3440
查看次数

libxml-ruby无法在x86_64加载

我们在服务器端遇到libxml-ruby gem问题可能因为它使用了x86_64架构:

$ 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: invalid ELF header - /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.4/lib/libxml_ruby.so
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.4/lib/libxml_ruby.so
from /usr/local/ruby-enterprise/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.4/lib/libxml.rb:9
from /usr/local/ruby-enterprise/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/ruby-enterprise/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from (irb):1
Run Code Online (Sandbox Code Playgroud)

宝石版1.1.4

重新安装宝石没有帮助可以有人建议做什么?

ruby elf libxml2 libxml-ruby

5
推荐指数
3
解决办法
5625
查看次数

ruby_xml_node.c:624:错误:解除引用指向不完整类型的指针

我尝试为Mac OS X安装libxml-ruby v2.3.3.

localhost:tmp$ uname -a
Darwin 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:26:45 PDT 2012; root:xnu-1699.32.7~1/RELEASE_I386 i386

localhost:tmp$ ruby -v
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin11.4.2]

localhost:tmp$ gem -v
1.8.24

gem install libxml-ruby -v '2.3.3'
Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
ERROR: Failed to build gem native extension.

    /Users/ruslan/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... no
checking for …
Run Code Online (Sandbox Code Playgroud)

rubygems ruby-on-rails libxml-ruby ruby-on-rails-3

5
推荐指数
0
解决办法
538
查看次数

使用libxml-ruby chunk处理大型XML文件

我想在Ruby中使用libxml 读取包含超过一百万个小书目记录(如)的大型XML文件<article>...</article>.我已经尝试将Reader类与该expand方法结合使用来按记录读取记录,但我不确定这是正确的方法,因为我的代码占用了内存.因此,我正在寻找一个如何方便地处理记录的配方,并且内存使用量不断增加.以下是我的主循环:

   File.open('dblp.xml') do |io|
      dblp = XML::Reader.io(io, :options => XML::Reader::SUBST_ENTITIES)
      pubFactory = PubFactory.new

      i = 0
      while dblp.read do
        case dblp.name
          when 'article', 'inproceedings', 'book': 
            pub = pubFactory.create(dblp.expand)
            i += 1
            puts pub
            pub = nil
            $stderr.puts i if i % 10000 == 0
            dblp.next
          when 'proceedings','incollection', 'phdthesis', 'mastersthesis':
            # ignore for now
            dblp.next 
          else
            # nothing
        end
      end  
    end
Run Code Online (Sandbox Code Playgroud)

这里的关键是dblp.expand读取整个子树(如<article>记录)并将其作为参数传递给工厂进行进一步处理.这是正确的方法吗?

在工厂方法中,我然后使用类似高级XPath的表达式来提取元素的内容,如下所示.再说一次,这可行吗?

def first(root, node)
    x = root.find(node).first
    x …
Run Code Online (Sandbox Code Playgroud)

ruby stream libxml-ruby

4
推荐指数
1
解决办法
3718
查看次数

无法加载此类文件 - libxml_ruby for Windows

我的步骤是,

  1. 执行RubyInstaller.exe文件
  2. 安装红宝石
  3. 安装路径:c:\ ruby​​193
  4. 安装DevKit
  5. gem install libxml-ruby --platform x86-mswin32-60
  6. make test.rb文件

    要求'rubygems'
    需要'xml'

  7. ruby test.rb

  8. 打印错误消息

错误信息:

C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
126: The specified module could not be found    - C:/Ruby193/lib/ruby/gems/1.9.1/gems/lib
xml-ruby-1.1.3-x86-mswin32-60/lib/libxml_ruby.so (LoadError)
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libxml-ruby-1.1.3-x86-mswin32-6    0/lib/libxml.rb:9:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libxml-ruby-1.1.3-x86-mswin32-6    0/lib/xml.rb:11:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
        from test.rb:2:in `<main>'
Run Code Online (Sandbox Code Playgroud)

我想要解决这个问题PLZ.帮我.

ruby gem libxml-ruby

4
推荐指数
1
解决办法
3462
查看次数

gem install libxml-ruby:致命错误:找不到'plist/Node.h'文件

试:

sudo gem install libxml-ruby -n /usr/local/bin
Run Code Online (Sandbox Code Playgroud)

输出:

Password:
Building native extensions. This could take a while...
ERROR:  Error installing libxml-ruby:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/libxml-ruby-3.1.0/ext/libxml
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180316-738-nk2zon.rb extconf.rb
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib …
Run Code Online (Sandbox Code Playgroud)

rubygems libxml-ruby

4
推荐指数
1
解决办法
1687
查看次数

如何解决 Windows 上“gem install ovirt-engine-sdk”上的“libxml2 missing package”错误?

我正在尝试gem install ovirt-engine-sdk在 Windows 10 机器上运行,但我面临以下问题:

extconf.rb:29:in `<main>': The "libxml2" package isn't available. (RuntimeError)

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/ovirt-engine-sdk-4.2.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/ovirt-engine-sdk-4.2.5 for inspection.
Results logged to
C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/ovirt-engine-sdk-4.2.5/gem_make.out

An error occurred while installing ovirt-engine-sdk (4.2.5), and Bundler cannot
continue.
Make sure that `gem install ovirt-engine-sdk -v '4.2.5'` succeeds before
bundling.

In Gemfile:
  fog was resolved to …
Run Code Online (Sandbox Code Playgroud)

ruby rubygems libxml2 libxml-ruby ovirt

2
推荐指数
1
解决办法
1657
查看次数

libxml-ruby 解析文件并从 xml 中获取所需信息

我正在使用 libxml-ruby gem 来读取 xml 字符串。

我无法从 xml 字符串中提取所需的信息。

目前我有以下xml

<?xml version="1.0" encoding="utf-8"?>
<message>
  <head>
    <api_key>252f5df2df522fg5fd25df2df5df2fd5</api_key>
    <user>123</user>
    <secret>********************</secret>
    <signature>****************</signature>
    <synchronization token="kj0s09ew090mv904v09409905b" last_synchronize_on="2010-01-02 11:30" />
  </head>
  <blockings>
    <blocking token="AAA" start_time="2010-01-01 10:00" end_time="2010-01-01 12:00" method="REQUEST" is_forced="FALSE" />
    <blocking token="BBB" start_time="2010-01-03 15:00" end_time="2010-01-03 18:00" method="REQUEST" is_forced="FALSE" />
  </blockings>
</message>
Run Code Online (Sandbox Code Playgroud)

我如何从这个 xml 字符串中获取 api_key、同步令牌、last_synchronize_on 值?

如何获取此字符串的阻塞节点内的阻塞节点的信息?

谢谢

ruby xml ruby-on-rails libxml-ruby xml-parsing

1
推荐指数
1
解决办法
2358
查看次数