{"id":7044,"date":"2014-05-17T00:24:27","date_gmt":"2014-05-17T00:24:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/how-do-i-get-the-p-tag-parent-class-name-using-nokogiri-collection-of-common-programming-errors\/"},"modified":"2014-05-17T00:24:27","modified_gmt":"2014-05-17T00:24:27","slug":"how-do-i-get-the-p-tag-parent-class-name-using-nokogiri-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/how-do-i-get-the-p-tag-parent-class-name-using-nokogiri-collection-of-common-programming-errors\/","title":{"rendered":"How do I get the &lt;p&gt; tag parent class name using Nokogiri?-Collection of common programming errors"},"content":{"rendered":"<p>This is a good use-case for XPath. Here&#8217;s how I&#8217;d go about it:<\/p>\n<pre><code>require 'nokogiri'\n\ndoc = Nokogiri::HTML( #\n<\/code><\/pre>\n<p>The <code>$<\/code> is a marker in CSS that says that particular part of the selector is what we&#8217;re interested in. See &#8220;Determining the Subject of a Selector&#8221; for more information. Once Nokogiri supports &#8220;subjects&#8221;, we can streamline our CSS selectors and their accompanying Ruby code because we won&#8217;t need to use <code>parent<\/code> methods to set up to the parent nodes. Until then, well, we still have the old works around of using <code>parent<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a good use-case for XPath. Here&#8217;s how I&#8217;d go about it: require &#8216;nokogiri&#8217; doc = Nokogiri::HTML( # The $ is a marker in CSS that says that particular part of the selector is what we&#8217;re interested in. See &#8220;Determining the Subject of a Selector&#8221; for more information. Once Nokogiri supports &#8220;subjects&#8221;, we can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7044","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7044"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7044\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}