ruby - How do I get the <p> tag parent class name using Nokogiri? -


i'm trying <p> tag's parent class name?

<div class="entry-content">    <p>some text...</p> </div> 

how can obtain this?

some find using css , nokogiri parent method easier read/maintain xpath:

html = %q{ <div class="entry-content">    <p>some text...</p> </div> }  doc = nokogiri::html(html) doc.css('p').each |p|     puts p.parent.attr('class') end 

Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -