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

  • SEARCH
  • Home
  • 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 8396507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:33:18+00:00 2026-06-09T20:33:18+00:00

Given the following XML file : <a m=1> <b n=1 o=2> <c p=3>3</c> <d/>

  • 0

Given the following XML file :

<a m="1">
    <b n="1" o="2">
        <c p="3">3</c>
        <d/>
    </b>
    <b n="1" o="2">
        <c p="3">3</c>
        <d q="3">
            <e r="2">2</e>
        </d>
        <f s="1"/>
    </b>
</a>

How can I find the following expressions :

1. count(/*/*/*)  =  5
2. count (/*//*)  = 6
3. count (/*/*//@*) = 4

I ran the xml file with those xpath expressions in Java , but I don’t understand why the answers are 5,6,4 .

Can someone please explain how can I calculate the above expressions (not using a java code) but by understanding the actual concept of the commands /*/*/* and /*//* and /*/*//@* ?

Much appreciated

  • 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-09T20:33:19+00:00Added an answer on June 9, 2026 at 8:33 pm
    /*/*/*
    

    This selects all “grand-children of the top element — these are: c, d, c, d

    /*//*
    

    This selects all descendant elements of the top element: b, c, d, b, c, d, e, f

    /*/*//@*
    

    This selects all attributes either of children of the top element or of their descendants: n, o, p, n, o, p, q, r, s.

    Therefore, the counts produced must be, respectively:

    4, 8, 9
    

    XSLT – based verification:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
    
     <xsl:template match="/">
       <xsl:value-of select="count(/*/*/*)"/>
    =========
       <xsl:value-of select="count(/*//*)"/>
    =========
       <xsl:value-of select="count(/*/*//@*)"/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is performed on the provided XML document (never, never ever present the document with a picture!!!):

    <a m="1">
     <b n="1" o="2">
       <c p="3">3</c>
       <d/>
     </b>
     <b n="1" o="2">
       <c p="3">3</c>
       <d q="3">
         <e r="2">2</e>
       </d>
     </b>
     <f s="1"/>
    </a>
    

    The Xpath expressions are evaluated and their results are copied to the output:

       4
    =========
       8
    =========
       9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following xml: <!-- file.xml --> <video> <original_spoken_locale>en-US</original_spoken_locale> <another_tag>somevalue</another_tag> </video> What would be
Given the following: >>> from lxml import etree >>> contents=open('file.xml').read() >>> node=etree.fromstring(contents) How would
Given the following repository URL from my pom.xml how can I determine what the
Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <application name=foo> <movie name=tc english=tce.swf chinese=tcc.swf
Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <process name=TestSVG2 xmlns=http://www.example.org targetNamespace=http://www.example.org xmlns:xsd=http://www.w3.org/2001/XMLSchema> <sequence>
Given the following XML file: <users> <user name=admin password=foobar roles=Admin,Guest /> <user name=guest password=foobar
I'm looking for code which can do the following. Given a snippet of XML,
Problem Given the following XML configuration file: <main> <name>JET</name> <maxInstances>5</maxInstances> <parameters> <a>1</a> <b> <b1>test1</b1>
I can't seem to figure this one out. I have the following XML file:
I would like your help in the following : given the .xml file :

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.