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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:55:51+00:00 2026-05-25T10:55:51+00:00

Okay, so I’ve got some example xml that looks like this: <Node name=details> <Node

  • 0

Okay, so I’ve got some example xml that looks like this:

<Node name="details">
   <Node name="1130482269">
      <Val name="type"><u>2</u></Val>
      <Val name="owner"><n/></Val>
      <Val name="account_number"><u>99-71-39</u></Val>
   </Node>
   <Node name="570722270">
      <Val name="type"><u>2</u></Val>
      <Val name="owner"><n/></Val>
      <Val name="account_number"><u>99 71 40</u></Val>
   </Node>
   <Node name="1845243341">
      <Val name="type"><u>2</u></Val>
      <Val name="owner"><n/></Val>
      <Val name="account_number"><u>9971-41</u></Val>
   </Node>
</Node>

I’m trying to do a search based on account_number. But there are so many different formats that it could be in. Some have spaces, some have dashes, some have a mixture etc. If I was able to do a search removing spaces and dashes, I should be able to get any account number.

With accountnumber being the search query, the ultimate goal is to get the second level node name number by doing a search in XPATH doing this:

doc = libxml2.parseDoc(xml)
ctxt = doc.xpathNewContext()
res = ctxt.xpathEval("/Node/Node[Val[@name='account_number']/*='" + str(accountnumber) + "']/@name")

Is there a way to use XPATH search, to remove all dashes and spaces, and leave only numbers?

Thanks

  • 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-25T10:55:51+00:00Added an answer on May 25, 2026 at 10:55 am

    Yes, it is possible using translate() function. Example:

    "translate(Node/Node[@name='1130482269']/Val[@name='account_number'],'- ','')"
    

    will output 997139.

    You can use then (code line broken for readability):

    "translate(
      /Node/Node[@name='" + 
      str(accountnumber) + 
      "']/Val[@name='account_number'],'- ','')"
    

    Note the white space included in the second argument of translate '- ' (or even '-&#x20;') necessary to remove white spaces.

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

Sidebar

Related Questions

Okay. I know this looks like the typical Why didn't he just Google it
Okay so im working on this php image upload system but for some reason
Okay, I might confuse some people who might be able to answer this question,
Okay, so I've got some C code to perform a mathematical operation which could,
Okay, I'm having some serious issues here. I'm new to this site, and new
Okay I got some good advice for Mobile Detection but still having an issue
Okay, first some background, I can't use any javascript library except YUI for this
Okay, so I've known about this for like 600 years now, but I've only
Okay, I've got a page with a header div that stretches 100% wide, with
Okay, so I'm running a small test webserver on my private network. I've got

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.