How to avoid a specific tag while extracting xpath
<p>By using xpath(.//div[@class="entry-content"]/div/p//text()') i am getting all the text1,text2,.....text6. How to take only "text3","text4","text5","text6"??</p>

<pre><code>`&lt;div class="entry-content"&gt;
   &lt;div&gt;
     &lt;p&gt;
     &lt;st&gt;text1&lt;/st&gt;
     &lt;/p&gt;
     &lt;p&gt;
     &lt;st&gt;text2&lt;/st&gt;
     &lt;/p&gt;
   &lt;/div&gt;
   &lt;p&gt;"text3"&lt;/p&gt;
   &lt;div&gt;
     &lt;p&gt;
     &lt;st&gt;"text4"&lt;/st&gt;
     &lt;/p&gt;
     &lt;p&gt;
     &lt;st&gt;"text5"&lt;/st&gt;
     &lt;/p&gt;
     &lt;p&gt;
     &lt;st&gt;"text6"&lt;/st&gt;
     &lt;/p&gt;
   &lt;/div&gt;
&lt;/div&gt;`
</code></pre>

<p>As per your clarification it seems that "p" are the nodes you want to avoid, in particular the first 2 of them. As they may appear at different depth level, one of the ways you achieve it is with this xpath expression, which is basically a variation of the solution provided by Michael Kay:</p>

<pre><code>//div[@class="entry-content"]//descendant::p[position()&gt;2]//text()
</code></pre>

python python-2.7 python-3.x xpath