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>If you only want nodes within the second <code>div</code>, use the path</p>

<pre><code>.//div[@class="entry-content"]/div[2]/p//text()
</code></pre>

<p>If want nodes in all <code>div</code>s except the first, write</p>

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

<p>If you want to select on some other basis, then explain what rules you want to apply. (Your question says "avoid a specific tag", but you are very <em>unspecific</em> about what tag you want to avoid).</p>

python python-2.7 python-3.x xpath