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 - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -