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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:12:27+00:00 2026-05-23T12:12:27+00:00

I have an XML document that contains items with dashes I’d like to strip

  • 0

I have an XML document that contains items with dashes I’d like to strip

e.g.

<xmlDoc>
   <items>
      <item>a-b-c</item>
      <item>c-d-e</item>
   <items>
</xmlDoc>

I know I can find-replace a single item using this xpath

/xmldoc/items/item[1]/translate(text(),'-','')

Which will return

“abc”

however, how do I do this for the entire set?

This doesn’t work

/xmldoc/items/item/translate(text(),'-','')

Nor this

translate(/xmldoc/items/item/text(),'-','')

Is there a way at all to achieve that?

  • 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-23T12:12:28+00:00Added an answer on May 23, 2026 at 12:12 pm

    I know I can find-replace a single
    item using this xpath

    /xmldoc/items/item[1]/translate(text(),'-','')
    

    Which will return

    "abc"
    

    however, how do I do this for the
    entire set?

    This cannot be done with a single XPath 1.0 expression.

    Use the following XPath 2.0 expression to produce a sequence of strings, each being the result of the application of the translate() function on the string value of the corresponding node:

    /xmlDoc/items/item/translate(.,'-', '')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have xpath, that obtains nodes, that don't have ancestor, which
I have created an XML document with the following contents. <books> <book id=1> <title>Title01</title>
I have a SOAP web service written in java communicating via XML-utf-8. My produced
I'd like to know if there is any simple way to deserialize decimal with
I have a XML created dynamically. However, I want to add a reference to
I am implementing spring security framework in my web app. I have all the
I've seen plenty of posts all around about this... but I can not, for
I run an XPath in Java with the following xml and code: <?xml version=1.0
I'm struggling few days with quite complex xpath and I'm not able to formulate
There might be some very simple answer to this, but i am really stuck

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.