From: Love U Ruby Date: 2013-06-17T04:08:58+09:00 Subject: Re: Nokogiri::XML::Node methods examples. #=================================================================================== # Day - IX : # Methods wil be covered: # #ancestors #=================================================================================== doc = Nokogiri::HTML(<<-eof)

OTHER SERVICES

eof doc.class # => Nokogiri::HTML::Document doc.at('ul.type-a').class # => Nokogiri::XML::Element doc.at('ul.type-a').children.reject{|i| i.text.strip == ""}.map(&:text) # => ["Complaints", # "Online Shopping", # "Foreign Travel/EZ-Pay/Gift Cards", # "Mobile Banking Services", # "NRI Services", # "OnlineSBI Global", # "SBI Express Remit", # "e-DFS/e-VFS", # "SBI F.A.S.T.", # "Secure Card Transactions", # "Net Banking for Visually Challenged", # "SBI e-File"] doc.at('ul.type-a').children.reject{|i| i.text.strip == ""}[2].ancestors.map(&:name) # => ["ul", "body", "html", "document"] -- Posted via http://www.ruby-forum.com/.