nokogiri

Nokogiri 1.5.2 not installing on Ubuntu 11.10

百般思念 提交于 2019-12-10 15:45:47
问题 Real quick, I am aware of a similar question. However, following the top rated answer does not work. I've already restarted my system and the terminal, but to no avail. For some reason, Nokogiri does not recognize that I have libxslt1-dev installed, though I explicitly installed it, both with sudo apt-get install libxslt-dev and sudo apt-get install libxslt1-dev . Here's the output; am I missing anything else? $ gem install nokogiri -v '1.5.2' Building native extensions. This could take a

Extracting HTML5 data attributes from a tag

时间秒杀一切 提交于 2019-12-10 14:53:47
问题 I want to extract all the HTML5 data attributes from a tag, just like this jQuery plugin. For example, given: <span data-age="50" data-location="London" class="highlight">Joe Bloggs</span> I want to get a hash like: { 'data-age' => '50', 'data-location' => 'London' } I was originally hoping use a wildcard as part of my CSS selector, e.g. Nokogiri(html).css('span[@data-*]').size but it seems that isn't supported. 回答1: Option 1: Grab all data elements If all you need is to list all the page's

/usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)

依然范特西╮ 提交于 2019-12-10 14:03:19
问题 having this problem on installing several things on my mac, i think this problem is coming from upgrading my leopard to snow leopard. Also this problem also is linked with macports i think. /usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64) Any ideas? Update To be more specific this happens on installing nokogiri gem and the log looks like: xslt_stylesheet.c:127: warning: passing argument 1 of ‘Nokogiri_wrap_xml_document’ with different

Test if a child node exists (without getting NoMethodError)

£可爱£侵袭症+ 提交于 2019-12-10 12:55:51
问题 <root> <channel> <one>example</one> <two>example2</two> </channel> <channel> <one>example</one> </channel> </root> In the second node, I don't have a <two> node. If I use this: root.channel.two obviously I get the error "Method missing". How can I check to avoid this error? What is the conditional statement I would use? 回答1: Technique 1: Rescue Any Error require 'nokogiri' d = Nokogiri.XML("<foo><bar /></foo>") bad = d.root.bar #=> undefined method `bar' for #<...> (NoMethodError) d.slop! yay

xpath for selecting <option> html tag?

强颜欢笑 提交于 2019-12-10 12:47:33
问题 xpath for selecting html tag ? <select> <option value="first option"> 1 </option> <option value="second option"> 2 </option> <option value="third option"> 3 </option> </select> Would below suffice ? html/body/form/select[@name='options' and @value='first option'] 回答1: Several options here: /html/body/form/select/option /html/body/form/select/option[1] /html/body/form/select/option[position() = 1] /html/body/form/select/option[@value='first option'] All these lead to first option element 回答2:

Heroku app crashes with 'libruby.so.1.9: cannot open shared object file' [closed]

落花浮王杯 提交于 2019-12-10 12:46:49
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I've never had problems deploying this app but I've just pushed and now I'm getting this weird error, which is deep enough in the stack that it's not

How to create XML from Yaml file using Nokogiri?

三世轮回 提交于 2019-12-10 12:24:51
问题 I want to read and open an .yml file and create an XML using Nokogiri ? Can anybody tell me how to do it ? This is the Yaml format: getOrderDetails: Id: '114' Name: 'XYZ' This is the XML I need: <product> <id>123</id> <name>xyz</name> </product> And this is the ruby file: require 'nokogiri' require 'rubygems' require 'spec/spec_helper' require 'yaml' @doc = YAML.load(File.open(File.expand_path('/Workspace/XML_Parsing/getDetails_api.yml'‌​))) @doc = File.open('/Workspace/XML_Parsing/getDetails

How can I extract the node names for fragmented XML document using Ruby?

泪湿孤枕 提交于 2019-12-10 12:15:52
问题 I an XML-like document which is pre-processed by a system out of my control. The format of the document is like this: <template> Hello, there <RECALL>first_name</RECALL>. Thanks for giving me your email. <SETPROFILE><NAME>email</NAME><VALUE><star/></VALUE></SETPROFILE>. I have just sent you something. </template> However, I only get as a text string what is between the <template> tags. I would like to be able to extract without specifying the tags ahead of time when parsing. I can do this

Eventmachine gem permission denied

空扰寡人 提交于 2019-12-10 12:15:05
问题 I'm trying to run $gem install eventmachine -v '0.12.10' because when running $bundle install within my rails app, when it gets to eventmachine I get this error: Installing eventmachine (0.12.10) Errno::EACCES: Permission denied - /Users/pippinlee/.rvm/gems/ruby-1.9.3-p194/gems/eventmachine-0.12.10/.gitignore An error occured while installing eventmachine (0.12.10), and Bundler cannot continue. Make sure that `gem install eventmachine -v '0.12.10'` succeeds before bundling. I have tried

Setting an attribute in a Nokogiri::XML::NodeSet with css

时光毁灭记忆、已成空白 提交于 2019-12-10 12:13:45
问题 I was trying to set an attribute for a specific element in an xml file and I was having success using doc.css('Object').attr("Id").value = timestamp This was fine until the situation where 'Object' doesn't exist causing an exception in the program and quitting. To avoid that I wanted to use Nodeset as it'll just be empty instead. doc.css('Object').each do |element| element.attr("Id").value = timestamp end However this returns with the error that value= is an undefined method. It's probably