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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:21:27+00:00 2026-06-04T04:21:27+00:00

I started to learn xpath at w3cschool. I am trying to evaluate the number

  • 0

I started to learn xpath at w3cschool. I am trying to evaluate the number of players in the game. (so counting the screenname and the text() elements/attributes)

Here is my example xml:

<game>
    <info>
        <name>My Game</name>
        <description>A <i>very</i> interesting game.</description>
        <started>2012-03-01T18:00:00Z</started>
        <players number="2">
            <screenname player="1">Alice</screenname>
            <screenname player="2">Bob</screenname>
        </players>
        <rounds>2</rounds>
        <winner player="2"/>
    </info>
</game>

the xpath query I use is:

//game/info/players[count(.//screenname/text())]

But I only get:

"Result is a NodeSet containing 1 element" 

(tool: http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm)

What causes this error?

  • 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-04T04:21:28+00:00Added an answer on June 4, 2026 at 4:21 am

    Your XPath query should probably be:

    count(/game/info/players/screenname)
    

    The XPath you are using now is asking for all game/info/players nodes which have a non-zero number of screenname/text() descendent nodes. Since there’s only one players element, the resulting nodeset contains only one element.

    Remember, an XPath is a series of axis-nodetest-predicate expressions (axis::nodetest[predicate]) separated by steps (/). Only axis-nodetest is part of the result set sent to the next step–the predicate never appears in a result set because it is only used to filter.

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

Sidebar

Related Questions

I have started to learn game physics and I am trying to move a
I just started to learn Django and I had a question. I'm trying to
I've started to learn Haskell and feeling overwhelmed with it. I'm now trying to
I just started to learn CakePHP and i'm trying to make the homepage (views\pages\home.ctp)
I have recently started to learn Objective-C and write my tests using OCUnit that
I have started to learn about python and is currently reading through a script
I have started to learn ANTLR and have both the 2007 book The Definitive
I recently started to learn how to use openCL to speed up some part
I just started to learn how to use action listeners. To my understanding it
When I started to learn about WPF and MVVM recently, I came across some

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.