nokogiri

cann't install nokogiri 1.6.1 on Mac OS X 10.9 Maveriks

只愿长相守 提交于 2019-12-24 10:07:05
问题 third day can't install nokogiri....Tried all instruction's from stack overflow and from official nokogiri page.Will be glad for any help,Thanx!!!! ruby -v 2.1 rvm -v 1.25.18 OS X 10.9.1 Xcode 5.0.2 Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix brew list apple-gcc42 grep libksba libxslt pcre sqlite autoconf

Using Nokogiri to search through XML file based on user input in Rails app

∥☆過路亽.° 提交于 2019-12-24 09:46:00
问题 So I've got an XML file (XML file) with a schema (XML schema). I'm trying to create a quick Rails app to allow users to search through the XML file based on the 'lastName" element that are children of an sdnEntry element. I don't have any problems setting up the rails app, or the search-form. I was also able to get the XML file loaded using Nokogiri and can run simple commands like... xmldoc.css("lastName") ...to return a NodeSet with all the 'lastName' elements in them. Unfortunately, that's

How can I use Ruby's Sanitize/Nokogiri to access untagged elements?

拥有回忆 提交于 2019-12-24 07:58:16
问题 I'm trying to build a Sanitize transformer that accepts potentially malformed HTML input with elements outside of any tags at all, such as in this example: out of a tag<p>in a tag</p>out again! I want to have the transformer wrap any non-tagged elements in <p> tags so that the above transforms into: <p>out of a tag</p><p>in a tag</p><p>out again!</p> Unfortunately, I can't figure out how to select the untagged element because it's not a node. I'm sure I'm missing something here. Can someone

How to stop insert implicit tags when using `Copy Xpath` in Chrome Developer tools

自古美人都是妖i 提交于 2019-12-24 07:36:05
问题 I use Copy Xpath function in Chrome developer tools for nokogiri xpath parser. But like this question, Chrome and Firefox's Developer tools insert tags like <tbody> implicitly. Is there a way to get "real" xpath that I can use for nokogiri xpath parser? 回答1: When you extract XPath from a browser, you do that form the actual DOM, where it is too late to know whether the <tbody> element was there or whether it was added implicitly. You can replace all instances of /tbody/ with // so you don't

Having trouble determining if element exists

孤者浪人 提交于 2019-12-24 07:10:20
问题 I have an xml document full of nested item nodes. In most cases, each item has a name element. I want to check if an item has a name element, and return a default name if one doesn't exist. <item> <name>Item 1</name> </item> <item> <items> <item> <name>Child Item 1</name> </item> <item> <name>Child Item 2</name> </item> </items> </item> When I ask node.at('name') for the node with no name element, it picks the next one from the children further down the tree. In the case above, if I ask at(

Repairing invalid HTML with Nokogiri (removing invalid tags)

半腔热情 提交于 2019-12-24 06:44:52
问题 I'm trying to tidy some retrieved HTML using the tidy-ext gem. However, it fails when the HTML is quite broken, so I'm trying to repair the HTML using Nokogiri first: repaired_html = Nokogiri::HTML.parse(a.raw_html).to_html It seems to do a nice job but lately I encountered a sample where people inserted FBML markup into the HTML document such as <fb:like> which is somehow preserved by Nokogiri although being invalid. Tidy then says Error: <fb:like> is not recognized! which is understandable.

How to remove all tags except for some using Nokogiri

元气小坏坏 提交于 2019-12-24 01:49:08
问题 How do I remove all tags below a certain node except for some elements using Nokogiri? For example, using this setup: src = <<EOS <html> <body> <p> Hello <i>world</i>! This is <em>another</em> line. <p><h3>And a paragraph <em>with</em> a heading.</h3></p> <b>Third line.</b> </p> </body> </html> EOS doc = Nokogiri::HTML(src) para = doc.at('//p') How can I remove all elements in the paragraph (while preserving their content) except <i> and <b> elements? So the result would be: <html> <body> <p>

How do I remove white space between HTML nodes?

瘦欲@ 提交于 2019-12-23 17:15:31
问题 I'm trying to remove whitespace from an HTML fragment between <p> tags <p>Foo Bar</p> <p>bar bar bar</p> <p>bla</p> as you can see, there always is a blank space between the <p> </p> tags. The problem is that the blank spaces create <br> tags when saving the string into my database. Methods like strip or gsub only remove the whitespace in the nodes, resulting in: <p>FooBar</p> <p>barbarbar</p> <p>bla</p> whereas I'd like to have: <p>Foo Bar</p><p>bar bar bar</p><p>bla</p> I'm using: Nokogiri

Install Nokogiri on Yosemite 10.10.3

左心房为你撑大大i 提交于 2019-12-23 13:02:33
问题 I have: Mac OS X Yosemite 10.10.3 MacPorts (not Brew) Ruby 2 in system (not RVM) I want to install Nokogiri and tried: port install nokogiri and got: Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150323-30174-1mqhl4i.rb extconf.rb checking if the C compiler accepts ... yes checking if the C compiler accepts -Wno-error=unused

Nokogiri error on installation due to missing native extension

邮差的信 提交于 2019-12-23 12:28:53
问题 I have been trying to install Ruby on Rails based on these instructions. However, I am getting the following error upon running gem install rails -v 4.2.4 : Fetching: rack-1.6.4.gem (100%) Successfully installed rack-1.6.4 Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /home/falak/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20150909-22683-172bl7d.rb extconf.rb checking if the C compiler accepts ... ***