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 6387511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:09:39+00:00 2026-05-25T03:09:39+00:00

I want to count the total number of specific nodes between root node and

  • 0

I want to count the total number of specific nodes between root node and current node.
for Example:

 <w:body> <!-- root Node -->
     <w:p/>
             <w:rect>
             <w:p>some text1</w:p>  
            </w:rect>
     <w:p/>
             <w:rect>
              <w:p>some text2</w:p>  
            </w:rect>

     <w:p/>
     <w:p/>
     <w:p/>
            <w:rect>
             <w:p>some text5</w:p>   <!-- This is current node now -->
            </w:rect>
     <w:p/>
     <w:p/>
     <w:p/>
     <w:p/>
</w:body>

This is my scenario.Here, Assume some text is my current node.So, Now i want to get the parent::w:p of the current node (Assume this node name as “targetNode”). After that i want to calculate total number of the same level of w:p from root node to targetNode.

My wanted output is :5

Please Guide me to get out of this issue…

  • 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-05-25T03:09:39+00:00Added an answer on May 25, 2026 at 3:09 am

    What about this single XPath expression:

     count(ancestor::w:p[1]/preceding-sibling::w:p + 1)
    

    In this way we obtain the count of all preceding sibling w:p nodes of the first ancestor w:p + 1 (the first ancestor w:p itself).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to count the total number of row in oledbconnection in c#.net I want
I need to count how many times some specific days appears between two given
i want to count total number of rows, sample : row1 = 1 row2
I want to count the total number of order detail rows over all orders
I want to count the total divs inside a container and toggle their visibilities
I want to count the number of set bits in a uint in Specman:
I want to count the number of accounts from the resulting table generated from
I am using Repeater in asp.net, i want to display total number of records.
I have 3 tables setup (items, reviews, ratings). I want to count the total
Currently its working but I want the xml to contain the total number of

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.