Note that there are some explanatory texts on larger screens.

plurals
  1. POsimple html dom parser get text without tag
    text
    copied!<p>I want to parse a HTML object using simple HTML DOM parser using PHP. The specific part that I want to extract is not wrapped in any tag properly.</p> <pre><code>&lt;li class="tags"&gt; Required text: &lt;span itemprop="testCat"&gt;&lt;a href="/topics/new-topic/index.html" title="New Topic" onclick="s_objectID=&amp;quot;http://www.example.com/topics/new-topic/index.html_1&amp;quot;;return this.s_oc?this.s_oc(e):true"&gt;New Topic&lt;/a&gt;&lt;/span&gt;, &lt;span itemprop="testCat"&gt;&lt;a href="/topics/new-topic-2/index.html" title="New Topic" onclick="s_objectID=&amp;quot;http://www.example.com/topics/new-topic-2/index.html_1&amp;quot;;return this.s_oc?this.s_oc(e):true"&gt;New Topic&lt;/a&gt;&lt;/span&gt;, &lt;span itemprop="testCat"&gt;&lt;a href="/topics/new-topic-3/index.html" title="New Topic 3" onclick="s_objectID=&amp;quot;http://www.example.com/topics/new-topic-3/index.html_1&amp;quot;;return this.s_oc?this.s_oc(e):true"&gt;New Topic 3&lt;/a&gt;&lt;/span&gt;, &lt;div class="more"&gt; &lt;a href="javascript: void(0);" class="more-trigger" onclick="s_objectID=&amp;quot;javascript: void(0);_1&amp;quot;;return this.s_oc?this.s_oc(e):true"&gt;more&lt;/a&gt; &lt;div class="more-tags" style="top: 15px; left: 0px; display: none;"&gt; &lt;div class="hd"&gt;&lt;/div&gt; &lt;div class="bd"&gt; &lt;ul id="topic-filedin"&gt; &lt;li&gt;Another Required Text : &lt;a href="/topics/new-topic-4/index.html" onclick="s_objectID=&amp;quot;http://www.example.com/topics/new-topic-4/index.html_1&amp;quot;;return this.s_oc?this.s_oc(e):true"&gt;New Topic 4&lt;/a&gt; &lt;/li&gt; &lt;li&gt;Topic Intended For : &lt;a href="/topics/for-kids/index.html" onclick="s_objectID=&amp;quot;http://www.example.com/topics/for-kids/index.html_1&amp;quot;;return this.s_oc?this.s_oc(e):true"&gt;For Kids&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="ft"&gt;&lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; SNI.Node.ArticleInfo.moreTags(); &lt;/script&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p>I am able to get the text wrapped inside the tag using </p> <pre><code>$categories = $single_content-&gt;find('li[class=tags] span'); foreach ($categories as $key) { echo $key-&gt;plaintext . '&lt;br&gt;'; } </code></pre> <p>I am unable to find out <code>Required text</code> and <code>Another Required Text</code> and <code>Topic Intended For</code>.</p>
 

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