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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:36:35+00:00 2026-05-30T13:36:35+00:00

Can someone explain the difference between text() and string() functions. I often use one

  • 0

Can someone explain the difference between text() and string() functions. I often use one with other, but it does not make any difference, both will get the string value of the xml node.

  • 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-30T13:36:36+00:00Added an answer on May 30, 2026 at 1:36 pm

    Can someone explain the difference between text() and string()
    functions.

    I. text() isn’t a function but a node test.

    It is used to select all text-node children of the context node.

    So, if the context node is an element named x, then text() selects all text-node children of x.

    Other examples:

    /a/b/c/text()
    

    selects all text-node children of any c element that is a child of any b element that is a child of the top element a.

    II. The string() function

    By definition string(exprSelectingASingleNode) returns the string value of the node.

    The string value of an element is the concatenation of all of its text-node descendents — in document order.

    Therefore, if in the following XML document:

    <a>
      <b>2</b>
      <c>3
        <d>4</d>
      </c>
      5
    </a>
    

    string(/a) returns (without the surrounding quotes):

    "
      2
      3
        4
    
      5
    "
    

    As we see, the string value reflects three white-space-only text-nodes, which we typically fail to notice and account for.

    Some XML parsers have the option of stripping-off white-space-only text nodes. If the above document was parsed with the white-space-only text nodes stripped off, then the same function:

    string(/a)
    

    now returns:

    "23
        4
      5
    "
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone explain the difference between these two, the first one is taken from
Can someone explain the difference between IN and EXISTS and NOT IN and NOT
can someone explain me the difference between those 2 classes? Why to use satic
Can someone explain the difference between apache mod_wsgi in daemon mode and django fastcgi
Can someone explain this to me? In particular the difference between: http://github.com/whymirror/greg and http://piumarta.com/software/peg/
Can someone please explain to me the difference between the AppSettings and ApplicationSettings sections
Can someone please explain me what's the difference between Swing and AWT? Are there
Can some one explain to me the difference between categories and inheritance in Objective
Ok can someone explain to me the difference between: <script src=http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php type=text/javascript></script> and <script
Can someone explain the difference between .last() and :last ? I can't seem to

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.