Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8942587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:33:03+00:00 2026-06-15T11:33:03+00:00

<p> <p> <h2> <p> <ul> <p>and two special regions:</p> <ul> <h2> <span class=editsection> <span

  • 0
<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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:33:04+00:00Added an answer on June 15, 2026 at 11:33 am

    This one should work for you:

    count(//p[preceding-sibling::h2[./span[@id='History']] and following-sibling::h2[./span[@id='Demography']]])
    

    You can test it with the following transformation:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <xsl:value-of select="count(//p[preceding-sibling::h2[./span[@id='History']] and following-sibling::h2[./span[@id='Demography']]])" />
        </xsl:template>
    </xsl:transform>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my discussion board I have a Post class. There are two special functions,
I want to join two tables in a special way, first table is devices
I want to apply a special class to the two last list items in
I have two DIVs: <div id=div1></div> <div id=div2></div> In special cases div2 takes z-index:999.
I want two special methods: one that runs for all URLs one that runs
I have two categories that need a special template. Each has one post and
I have two classes which represent a special kind of numeric value. Let's call
I've got a select with two 'special' options, a bit like this: <select> <option
I want to define a custom exception that has two special properties: Field and
I have two php files so far, test.php: <?php include(../config_conn_fordon_db.php); include(../config_open_db.php); // Fix Special

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.