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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:17:13+00:00 2026-06-14T13:17:13+00:00

Can you get the text() of a jxpath element or does it not work?

  • 0

Can you get the text() of a jxpath element or does it not work?

given some nice xml:

<?xml version="1.0" encoding="UTF-8"?>
<AXISWeb xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AXISWeb.xsd">
    <Action>
    <Transaction>PingPOS</Transaction>
    <PingPOS>
        <PingStep>To POS</PingStep> 
        <PingDate>2012-11-15</PingDate> 
        <PingTime>16:35:57</PingTime> 
    </PingPOS>
    <PingPOS>
        <PingStep>POS.PROCESSOR18</PingStep> 
        <PingDate>2012-11-15</PingDate> 
        <PingTime>16:35:57</PingTime> 
    </PingPOS>
    <PingPOS>
        <PingStep>From POS</PingStep> 
        <PingDate>2012-11-15</PingDate> 
        <PingTime>16:35:57</PingTime> 
    </PingPOS>
</Action>
</AXISWeb>

//Does not work:

jxpc.getValue("/AXISWeb/Action/PingPOS[1]/PingStep/text()");

//Does not work:

jxpc.getValue("/action/pingPOS[1]/PingStep/text()");

//Does not work:

jxpc.getValue("/action/pingPOS[1]/PingStep[text()]");

I know I can get the text from using

jxpc.getValue("/action/pingPOS[1]/PingStep");

But that’s not the point.
Shouldn’t text() work? I could find no examples….

P.S. It’s also very very picky about case and capitalization. Can you turn that off somehow?

Thanks,
-G

  • 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-14T13:17:14+00:00Added an answer on June 14, 2026 at 1:17 pm

    /AXISWeb/Action/PingPOS[1]/PingStep/text() is valid XPath for your document

    But, from what I can see from the user guide of jxpath (note: I don’t know jxpath at all), getValue() is already supposed to return the textual content of a node, so you don’t need to use the XPath text() at all.

    So you may use the following:

    jxpc.getValue("/AXISWeb/Action/PingPOS[1]/PingStep");
    

    Extracted from the user guide:

    Consider the following XML document:

    <?xml version="1.0" ?>
    <address>
      <street>Orchard Road</street>
    </address> 
    

    With the same XPath, getValue("/address/street"), will return the string "Orchard Road", while
    selectSingleNode("/address/street") – an object of type Element (DOM
    or JDOM, depending on the type of parser used). The returned Element
    is, of course, <street>Orchard Road</street>.

    Now about case insensitive query on tag names, if you are using XPath 2 you can use lower-case() and node() but this is not really recommended, you may better use correct names.

    /*[lower-case(node())='axisweb']/*[lower-case(node())='action']/...
    

    or if using XPath 1, you may use translate() but it gets even worse:

    /*[translate(node(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'axisweb']/*[translate(node(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'action']/...
    

    All in all, try to ensure that you use correct query, you know it is case sensitive, so it’s better to pay attention to it. As you would do in Java, foo and fOo are not the same variables.


    Edit:

    As I said, XML and thus XPath is case sensitive, so pingStep cannot match PingStep, use the correct name to find it.

    Concerning text(), it is part of XPath 1.0, there is no need for XPath 2 to use it. The JXPath getValue() is already doing the call to text() for you. If you want to do it yourself you will have to use selectSingleNode("//whatever/text()") that will returns an Object of type TextElement (depending on the underlying parser).

    So to sum up, the method JXPathContext.getValue() already does the work to select the node’s text content for you, so you don’t need to do it yourself and explicitly call XPath’s text().

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

Sidebar

Related Questions

I Have been fiddling with this for hours. I can not get my text
How can I get the selected text (not the selected value) from a drop-down
How can I get text at mouse position? I have now some like this
does someone know how I can get Sublime Text 2 to auto-hide the tabs
How can I get text between tags [b][/b] from this text? Here is some
Simply enough I can't get text to align to right in a <label> element.
For some reason, I can't get text to show up in my list view.
I have a piece of code (below) that can get the text of an
My question is, how can I get text from header in javascript? So if
How can I get the text in this markup? <div itemprop=description> <p>Testing article....</p> <div

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.