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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:58:58+00:00 2026-05-10T17:58:58+00:00

I have an xml file where I need to comment out a whole piece

  • 0

I have an xml file where I need to comment out a whole piece of text with Ant.

There’s this Ant task

<replace file='${src.dir}/Version.as'           token='@revisionPrana' value='${revision}'/> 

that I use to replace words, but in my case I need to replace a whole block like this:

<value>   <object class='edumatic.backoffice.view.modules.NavigationModuleInfo'>     <property name='url'      value='edumatic/backoffice/view/modules/support/ExamsNavigationModule.swf'/>     <property name='icon'      value='edumatic/backoffice/view/modules/support/assets/book.png' />     <property name='title' value='Assessments' />     <property name='pluginID' value='EXAM' />   </object> </value> <value>   <object class='edumatic.backoffice.view.modules.ContentModuleInfo'>     <property name='url'      value='edumatic/backoffice/view/modules/support/ExamsContentModule.swf' />     <property name='pluginID' value='EXAM' />   </object> </value> 

Into

<!--value>   <object class='edumatic.backoffice.view.modules.NavigationModuleInfo'>     <property name='url'      value='edumatic/backoffice/view/modules/support/ExamsNavigationModule.swf'/>     <property name='icon'      value='edumatic/backoffice/view/modules/support/assets/book.png' />     <property name='title' value='Assessments' />     <property name='pluginID' value='EXAM' />   </object> </value> <value>   <object class='edumatic.backoffice.view.modules.ContentModuleInfo'>     <property name='url'      value='edumatic/backoffice/view/modules/support/ExamsContentModule.swf' />     <property name='pluginID' value='EXAM' />   </object> </value--> 

So, basically I need to comment out a whole block of XML. Can I do this with a replace task (putting the whole block in the attribute token and value doesn’t really work)? Or is there a quick way to read in the xml with ant and delete some nodes and save the xml again?

Searching for and replace it by isn’t an option because there are multiple value children and not all of them need to be commented out.

Adding a attribute like isn’t an option either because the xml is being parsed by an IOC container (Prana). Maybe prana will ignore the id=’1′ but it still iss messy, and I don’t like messy on the long term.

  • 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. 2026-05-10T17:58:58+00:00Added an answer on May 10, 2026 at 5:58 pm

    If you can identify what is to be replaced through a regular expression, I recommend using the optional task replaceregexp. Here’s the doc: http://ant.apache.org/manual/Tasks/replaceregexp.html You can call it twice, one for the start tag and other for the end tag.

    The regexp for replacing your can be a bit cumbersome, since you say you do not want to replace all tags, but I think this is the easiest way.

    Another option would be to create a custom ant task to do what you want.

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

Sidebar

Related Questions

i have created a xml file from database. this xml file i need to
I have an xml file I need to modify: ... </web-app> I want to
I have a xml file which I need to open with Microsoft Word 2007.
I have an XML file and I need to extract testname from all the
I have an XML file which I need to parse using PHP and send
i have an xml file sitemap.xml as shown below ..i need to add one
I have an XML file consisting of Name/Value pairs that I need in a
HI I have an xml file with 500KB size which i need to send
I have a dynamic products xml file that i need to load from an
I have a list of inactive_products in an XML file. I need to update

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.