Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><code>I get content from all &lt;code&gt; tags. And I don't want content from &lt;code class="smth"&gt;, I want content only from &lt;code&gt; without any class.</code></p> </blockquote> <p>You can use <code>[!attribute]</code> wich matches elements that don't have the specified attribute... In your case you should try <code>code[!class]</code></p> <p>As example, here's a working code getting all anchors not having the <code>target</code> attribute:</p> <pre><code>// includes Simple HTML DOM Parser include "simple_html_dom.php"; $text = '&lt;div&gt; &lt;a href="#" &gt;OK 1&lt;/a&gt; &lt;a href="#" target="_blank"&gt;Not needed&lt;/a&gt; &lt;a href="#" &gt;OK 2&lt;/a&gt; &lt;a href="#" target="_blank"&gt;Not needed&lt;/a&gt; &lt;a href="#" &gt;OK 3&lt;/a&gt; &lt;a href="#" target="_blank"&gt;Not needed&lt;/a&gt; &lt;a href="#" &gt;OK 4&lt;/a&gt; &lt;/div&gt;'; //Create a DOM object $html = new simple_html_dom(); // Load HTML from a string $html-&gt;load($text); // Get all anchors not having target as attribute $anchors = $html-&gt;find('div a[!target]'); // loop and print nodes content foreach( $anchors as $i =&gt; $anchor ) { echo "$i =&gt; ".$anchor-&gt;outertext."&lt;br/&gt;"; } // Clear dom object $html-&gt;clear(); unset($html); </code></pre> <p><em>OUTPUT:</em></p> <pre><code>0 =&gt; OK 1 1 =&gt; OK 2 2 =&gt; OK 3 3 =&gt; OK 4 </code></pre> <p><a href="http://phpfiddle.org/main/code/myc-g7n" rel="nofollow"><code>Working DEMO</code></a></p> <p><strong>Edit:</strong></p> <p>After inspection of the raw code, here's a way to get the wanted parts... Just to give you the idea, of course you can still improve it:</p> <pre><code>// includes Simple HTML DOM Parser include "simple_html_dom.php"; $url = 'http://getuikit.com/docs/grid.html'; //Create a DOM object $html = new simple_html_dom(); // Load HTML from a string $html-&gt;load_file($url); // Get all nodes with "tm-article-subtitle"... $nodes = $html-&gt;find('.tm-article-subtitle'); // loop and print nodes content foreach( $nodes as $i =&gt; $node ) { // Filter only those containing "Markup" if (stripos($node-&gt;plaintext, "Markup") !== false) { echo "&lt;pre&gt;$i =&gt; "; // The wanted code in pre can be 1 or 2 position far from "Markup" if(stripos($node-&gt;next_sibling()-&gt;tag, "pre") !== false) echo htmlentities($node-&gt;next_sibling()-&gt;outertext); elseif(stripos($node-&gt;next_sibling()-&gt;next_sibling()-&gt;tag, "pre") !== false) echo htmlentities($node-&gt;next_sibling()-&gt;next_sibling()-&gt;outertext); echo "&lt;/pre&gt;"; } } // Clear dom object $html-&gt;clear(); unset($html); </code></pre> <p><em>OUPUT</em></p> <pre><code>1 =&gt; &lt;pre&gt;&lt;code&gt;&amp;lt;div class="uk-grid"&amp;gt;... 5 =&gt; &lt;pre&gt;&lt;code&gt;&amp;lt;div class="uk-grid"&amp;gt;... 8 =&gt; &lt;pre&gt;&lt;code&gt;&amp;lt;div class="uk-grid uk-g... 10 =&gt; &lt;pre&gt;&lt;code&gt;&amp;lt;div class="uk-grid"&amp;gt... 12 =&gt; &lt;pre&gt;&lt;code&gt;&amp;lt;div class="uk-grid" data-uk-grid-match&amp;gt;...&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/pre&gt; 14 =&gt; &lt;pre&gt;&lt;code&gt;&amp;lt;div class="uk-grid" data-uk-grid-match=... 16 =&gt; &lt;pre&gt;&lt;code&gt;&amp;lt;ul class="uk-grid" data-uk-grid-margin&amp;gt; &amp;lt;!-- Th </code></pre> <p><a href="http://phpfiddle.org/main/code/abv-4rd" rel="nofollow"><code>Working DEMO</code></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload