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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:25:04+00:00 2026-06-16T17:25:04+00:00

I need to update several nodes in an XML file (just substitute one text

  • 0

I need to update several nodes in an XML file (just substitute one text element for the other) in such way that resulting XML file will keep all its formatting (where possible).

For example, the following is the source document:

<project>
    <!-- Some long comment -->
    <!-- On several lines -->
    <name>Name</name> <!-- And here too -->
    <version>1.2.3</version>

</project>

and this is the required result document (note that the version has changed):

<project>
    <!-- Some long comment -->
    <!-- On several lines -->
    <name>Name</name> <!-- And here too -->
    <version>3.2.1</version>

</project>

So the result keeps all the formatting from source, and only version tag content has changed.

Unfortunately, I couldn’t find a way to do this with standard Clojure (or Java) libraries. Sure, they do support basic indentation of string representation of XML, but it is not sufficient for me.

Is there a way to do this with some XML manipulation library (preferably in Clojure, but I guess Java is fine too), or I have to fall back to plain text/regexp substitutions? (really, I don’t want XML tags leaking from my eyes, this should the last resort…)

  • 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-16T17:25:05+00:00Added an answer on June 16, 2026 at 5:25 pm

    Perhaps a hybrid approach, parse the XML with clojure.xml to find the exact text you want to replace, and ensure that you are changing the correct spot. Then use string replacement to change it. I’m hesatent to advise using regular expressions to parse XML

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

Sidebar

Related Questions

Im in the need to update several #divs on a page by using AJAX
I need to update my .htaccess file to redirect permanently all URLs from http://example.com/pages/5604/article/something/?page=299
I need to update the META-INF.MF file of war The problem is My war
I need to update more than one update statements, but all should work on
I have several categories in which I need to update/assign the parent category so
I have several datagrid where I need to update the informations. Things is, since
Every day i need update several tables and add some new files to my
I need to update several records in a table, and am hoping to accomplish
I need to update InstrumentInfo class frequently. I update this class from one thread
I need to update a website that is moving to a new host. I

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.