• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ANT Task to modify XML files?

 
a chang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a custom ant task to modify an ant task build.xml file. What ant tasks are available to parse and modify an xml file? I want to find a property element with a specific name, and change an attribute called value. Any help would be great! thanks in advance!
 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not aware of any tasks that are packaged with ant that can accomplish this. I always recommend extending ant and writing your own task. This is pretty easy to do. There is a task - org.apache.tools.ant.taskdefs.XmlProperty - but it only loads properties from an xml file.

You could either parse the xml or if it is a specific element, you could write a routine to search and replace the value of that element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic