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
Post a Comment