<p>
<p>
<h2>
<p>
<ul>
<p>and two special regions:</p>
<ul>
<h2>
<span class="editsection">
<span id="History" class="mw-headline">History</span>
</h2>
<div class="thumb tleft">
<p>
<p>
<h3>
<p>
<div class="thumb tright">
<div class="thumb tright">
<p>
<p>
<h3>
<p>
<h3>
<div class="thumb tright">
<p>
<p>
<p>
<p>
<p>
<p>
<h3>
<p>
<h2>
<span class="editsection">
<span id="Demography" class="mw-headline">Demography</span>
</h2>
<div class="thumb tright">
<p>
<div class="thumb tright">
<p>
<table class="wikitable sortable jquery-tablesorter">
<p>
<p>
<p>
How to count the number of <P> tags in between two <h2> tags?
Start with tag
<h2>
<span class="editsection">
<span id="History" class="mw-headline">History</span>
</h2>
and
<h2>
<span class="editsection">
<span id="Demography" class="mw-headline">Demography</span>
</h2>
the xpath should retreive 13 <p> tags between these two <h2> tag. So how to do write xpath for this?
Note: Tags <p> <h2> <h3> <ul> <div> are siblings.
<p> tags and <h2> tags does’t contain any of the attribute.
This one should work for you:
You can test it with the following transformation: