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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:38:59+00:00 2026-05-21T07:38:59+00:00

I have just started learning XPath and I am learning the language without the

  • 0

I have just started learning XPath and I am learning the language without the abbreviation first.

When a location path starts with the character ‘/’ the initial context node is forces to be the root node…

Sample xml from book:

<widget type="gadget">
    ...
</widget>

If I am supposed to write the XPath so I get the type attribute why do I have to write:

/child::widget/attribute::type

and not like this /attribute::type

Have I misunderstood something about the root node or? Because I thought ‘/’ and widget was the same…

Thank you

  • 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-21T07:38:59+00:00Added an answer on May 21, 2026 at 7:38 am

    From http://www.w3.org/TR/xpath/#attribute-nodes

    Each element node has an associated
    set of attribute nodes; the element is
    the parent of each of these attribute
    nodes; however, an attribute node is
    not a child of its parent element.

    Only element nodes have attributes.

    The root node is not an element. From http://www.w3.org/TR/xpath/#root-node

    The root node is the root of the tree.
    A root node does not occur except as
    the root of the tree. The element node
    for the document element is a child of
    the root node. The root node also has
    as children processing instruction and
    comment nodes for processing
    instructions and comments that occur
    in the prolog and after the end of the
    document element.

    Thus you cannot select attributes of the root node like in /@* or /attribute::*

    You ask:

    Have I misunderstood something about
    the root node or?

    Yes. You should not confuse the root node (an abstraction) with the document element (some times also called the element root)

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

Sidebar

Related Questions

I have just started learning XNA. This is my first program that I am
I have just started learning PHP, and here's my first doubt... Both of these
I have just started learning Perl scripting language and have a question. In Perl,
I have just started learning Ruby. Very cool language, liking it a lot. I
I've just started learning XML & XSLT and have a quick question regarding Xpath.
I have just started learning python version 3 and trying to create a file
I have just started learning Rails, is it required for me to learn CoffeeScript
I have just started learning Jquery and am new to writing javascript (I am
I have just started learning MVVM and having a dilemna. If I have a
I have just started learning NHibernate. Over the past few months I have been

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.