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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:18:18+00:00 2026-06-14T15:18:18+00:00

I was learning XPath using the following xml document: http://www.w3schools.com/xpath/xpath_examples.asp Now, when I execute

  • 0

I was learning XPath using the following xml document: http://www.w3schools.com/xpath/xpath_examples.asp

Now, when I execute the query:

bookstore/book/author[contains(.,'G')]

I get the result: Giada De Laurentiis, James McGovern as expected. Now, since contains() returns a boolean value, I expected the following query to return all authors:

bookstore/book/author[true]

however, it returns an empty set. Can somebody explain?

  • 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-14T15:18:19+00:00Added an answer on June 14, 2026 at 3:18 pm

    I expected the following query to return all authors:

    bookstore/book/author[true]
    

    however, it returns an empty set. Can somebody explain?

    The above expression selects all bookstore/book/author elements that have a child element named true. In the provided XML document no author element has a child named true — therefore the XPath expression selects nothing.

    In a comment the OP asks:

    But why does bookstore/book/author[true] not work, since if is
    similar to the situation when the contains() always returns true

    contains() never returns (the string) “true” — it returns the boolean value true() — this is different from the string “true”.

    Explanation:

    You are confused by the fact that the serialization of the boolean value true() to sting is the string “true”.

    This fact doesnt mean that the string “true” and the boolean value true() are identical.

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

Sidebar

Related Questions

Please consider this sample file: http://www.w3schools.com/dom/books.xml This XPath expression //title/text() , returns: Everyday Italian
Hello I am trying to read my xml document using xpath. I have been
I am learning scraping using the PHP Simple HTML DOM Parser and Xpath. Accroding
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I'm learning Xpath and XSLT using Python 2.6.6-64bit on my unix workstation. For Xpath,
I know how to find what I need from XML using XPath. The syntax
I've just started learning XML & XSLT and have a quick question regarding Xpath.
learning the basics of Python, now ready for a bigger challange... it didn't take
Learning asp.net mvc and whenever I worked we had to localize our application. Looked
Learning sed, I want to change the drive letter of the following input lines

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.