nokogiri

on Linux, how can I resolve WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 ?

时光毁灭记忆、已成空白 提交于 2019-12-06 19:04:28
问题 Mac users, see: Mac user and getting WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.7.3 I'm using linux (openSUSE 12.3) and running nokogiri -v shows: WARNING: Nokogiri was built against LibXML version 2.8.0, but dynamically loaded 2.9.0 # Nokogiri (1.6.0) --- warnings: - Nokogiri was built against LibXML version 2.8.0, but dynamically loaded 2.9.0 nokogiri: 1.6.0 ruby: version: 2.0.0 platform: x86_64-linux description: ruby 2.0.0p247 (2013-06-27

Nokogiri adds characters during parsing on Heroku

血红的双手。 提交于 2019-12-06 16:12:56
It seems like Nokogiri has a problem with UTF-8 conversion of the nbsp character. I've gathered this is an issue related to LibXML2. Nokogiri recommends upgrading LibXML2 to 2.7.7 instead of 2.7.6 that's running on Heroku. Anyone know how I can use LibXML2 2.7.7 (or higher) on Heroku? The problem is as follows -- doc = Nokogiri::HTML("<html><p>Hi Hello</p></html>") doc.inner_html => "<html><body><p>Hi Hello</p></body></html>" doc.inner_html = "<p>Hello World</p>" => "<p>Hello World</p>" doc.inner_html => "<p>Hello World</p>" Looks like this is related: https://github.com/sparklemotion

Use XPath to group siblings from an HTML/XML document?

☆樱花仙子☆ 提交于 2019-12-06 15:32:41
I want to transform an HTML or XML document by grouping previously ungrouped sibling nodes. For example, I want to take the following fragment: <h2>Header</h2> <p>First paragraph</p> <p>Second paragraph</p> <h2>Second header</h2> <p>Third paragraph</p> <p>Fourth paragraph</p> Into this: <section> <h2>Header</h2> <p>First paragraph</p> <p>Second paragraph</p> </section> <section> <h2>Second header</h2> <p>Third paragraph</p> <p>Fourth paragraph</p> </section> Is this possible using simple Xpath selectors and an XML parser like Nokogiri? Or do I need to implement a SAX parser for this task?

How do I parse XML using Nokogiri and split a node value?

半城伤御伤魂 提交于 2019-12-06 15:27:45
I'm using Nokogiri to parse XML. doc = Nokogiri::XML("http://www.enhancetv.com.au/tvguide/rss/melbournerss.php") I wasn't sure how to actually retrieve node values correctly. I'm after the title , link , and description nodes in particular that sit under the item parent nodes. <item> <title>Toasted TV - TEN - 07:00:00 - 21/12/2011</title> <link>http://www.enhancetv.com.au/tvguide/</link> <description>Join the team for the latest in gaming, sport, gadgets, pop culture, movies, music and other seriously fun stuff! Featuring a variety of your favourite cartoons.</description> </item> What I'd

Is there a way to select all the contents of a node?

 ̄綄美尐妖づ 提交于 2019-12-06 14:42:30
Is there a way to select all the contents of a node in Nokogiri? <root> <element>this is <hi>the content</hi> of my æøå element</element> </root> The result of getting the content of /root/element should be: this is <hi>the content</hi> of my æøå element Edit: It seems like the solution is simply to use myElement.inner_html() . The problem I had was in fact that I was relying on an old version of libxml2, which escaped all the special characters. shingara Nokogiri.parse('<root><element>this is <hi>the content</hi> of my element</element></root>').css('element').inner_html If you want escape

Nokogiri XML import feed organisation?

Deadly 提交于 2019-12-06 14:40:49
问题 I have built a site that relies on an XML feed that I currently parse with Nokogiri. Everything works fine and dandy although I have all the code currently within my Admin controller so I can actually invoke the import via a URL i.e. /admin/import/ . I can't help but think that this doesn't belong in the controller. Is there a better way to do this, i.e. move the code into a stand alone import.rb file so it is only accessible from the console? If so where would I need to put this file, in the

Gem File won't update or install with bundler

点点圈 提交于 2019-12-06 13:38:59
问题 I'm working on Michael Hartl's RoR tutorials. I'm on chapter 3. Unfortunately, copy and pasting the gem files won't work for me, but I figured out which gem is the problem. It's the capybara gem. I've commented it out and continued the tutorial, but I'm at the point where I need to use the gem. Here is an example $bundle update giving me an error: $ bundle update Fetching gem metadata from https://rubygems.org/......... (Removed a bunch of text) Building nokogiri using system libraries. Gem:

Get the values of attributes with namespace, using Nokogiri

狂风中的少年 提交于 2019-12-06 13:27:50
I'm parsing a document.xml file using Nokogiri, extracted from .docx file and need to get values of attributes with names, like " w:val ". This is a sample of the source XML: <w:document> <w:body> <w:p w:rsidR="004D5F21" w:rsidRPr="00820E0B" w:rsidRDefault="00301D39" pcut:cut="true"> <w:pPr> <w:jc w:val="center"/> </w:pPr> </w:body> </w:document> This is a sample of the code: require 'nokogiri' doc = Nokogiri::XML(File.open(path)) doc.search('//w:jc').each do |n| puts n['//w:val'] end There is nothing in the console, only empty lines. How can I get the values of the attributes? require

Why doesn't nokogiri install?

不想你离开。 提交于 2019-12-06 11:58:34
I'm having a devil of a time installing Nokogiri on Ubuntu 12.04. I use rbenv. $ gem install nokogiri -v '1.6.1' ERROR: While executing gem ... (Errno::EACCES) Permission denied - /home/deploy/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1/.autotest $ sudo gem install nokogiri -v '1.6.1' ERROR: Error installing nokogiri: nokogiri requires Ruby version >= 1.9.2. $ rbenv sudo gem install nokogiri -v '1.6.1' Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /home/deploy/.rbenv/versions/2.0.0

possible to load nokogiri in jruby without installing nokogiri-java?

无人久伴 提交于 2019-12-06 11:21:36
问题 i need a way to run following nokogiri script #parser.rb require 'nokogiri' def parseit() //... end and call the parseit() while running below main.rb in jruby #main.rb require 'parser' parseit() Of course the problem is jruby cannot find 'nokogiri' as I have not installed it aka nokogiri-java via jruby -S gem install nokogiri The reason is there is some bug I found in nokogiri running under Jruby, so I have only installed nokogiri on Ruby not Jruby. The parser.rb runs perfectly under just