KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Let's say my HTML document is like: <div class="headline">News</div> <p>Some interesting news here</p> <div class="headline">Sports</div> <p>Baseball is fun!</p> I can get the headline divs with the following code: require 'rubygems' require 'nokogiri' require 'open-uri' url = "mypage.html" doc = Nokogiri::HTML(open(url)) doc.css(".headline").each do |item| puts item.text end But how do I access the content in the following p tag so that News is related to Some interesting news here , etc?
Tags (comma-separated)
Save Edits
Cancel