hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

New, Little Hpricot Pulps #

by why in bits

Element#css_path

 doc.at("div > div:nth(1)").css_path
   #=> "div > div:nth(1)" 
 doc.at("#header").css_path
   #=> "#header" 

Element#xpath

 doc.at("div > div:nth(1)").xpath
   #=> "/div/div:eq(1)" 
 doc.at("#header").xpath
   #=> "//div[@id='header']" 

Element#swap

 doc = Hpricot("That's my <b>spoon</b>, Tyler.")
 doc.at("b").swap("<i>fork</i>")
 doc.to_html
   #=> "That's my <i>fork</i>, Tyler." 

Element#next_sibling, Element#previous_sibling

 (doc/:h3).each do |h3|
   while ele = h3.next_sibling
     ary << ele   # stuff away all the elements under the h3
   end
 end

Raise a flag for pre-release gems, both source and win32:
gem install hpricot --source code.whytheluckystiff.net.

said on 25 Oct 2006 at 15:30

Next sibling! Finally, awesome!

said on 26 Oct 2006 at 11:17

smooch

said on 26 Oct 2006 at 11:17

smooch

said on 27 Oct 2006 at 06:42

The world is upside down: We get CSS 3 selector happiness in our programming tools before we get it in the browsers we present our work in.

said on 27 Oct 2006 at 22:03

This is wonderful—thanks so much _why! Ask and you shall receive!

said on 29 Oct 2006 at 21:38

Great. TY.

said on 01 Nov 2006 at 21:39

Hpricot is hot! Hpricot saves! Hpricot makes your colleagues think you are a pretty smart cookie. Three cheers!

11 Jul 2010 at 21:06

* do fancy stuff in your comment.

PREVIEW PANE