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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:17:41+00:00 2026-05-26T14:17:41+00:00

I am using Ant to build my software. Ant creates an Xml file with

  • 0

I am using Ant to build my software. Ant creates an Xml file with the echoxml function and then provides the created xml file to another special program.

Now I would like to list the content of a directory in the echoxml tag.

How can this be done? My final xml file should look something like this, only providing a path to the directory:

<SomeXmlTag>

<cp>directory/firstFile.jar</cp>

cp>directory/secondFile.jar</cp>

<cp>directory/XYZFile.jar</cp>

</SomeXmlTag>

  • 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-26T14:17:42+00:00Added an answer on May 26, 2026 at 2:17 pm

    EchoXML is an ant tast which is already specified to take a nested xml string as its contents, outputting those contents directly to a file (or to the console). So according to the documentation, it doesn’t satisfy your needs.

    However, it is pretty simple to modify a standard ant task to do this using the javax xml extensions and along with a the File api.

    First, See http://ant.apache.org/manual/Tasks/echoxml.html, and confirm that EchoXML does not do what you need it to do.

    Now, a simple solution is to implement your own xml writer task … to simply write your own class :

    public class MyFileTreeWriter extends Task {
        public void execute() {
               File dirs = new File("./");
               //Alternatively, you can use apache's FileUtils directory walkers https://commons.apache.org/io/api-1.4/index.html?org/apache/commons/io/DirectoryWalker.html      
    
      // Psuedo code below,  uses standard javax.xml.* packages ... 
      for (String file : dirs.listFiles()){
      Element em = document.createElement("file");
      em.appendChild(document.createTextNode(file);
      rootElement.appendChild(em); 
    
        }
    }
    

    And then add this to your build :

    <target name="use" description="MyFileTreeWriter task" depends="jar">
        <taskdef name="writeDirs" classname="MyFileTreeWriter" classpath="${ant.project.name}.jar"/>
    </target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using an ant build file that has been generated by android. Our Android
I'm using ANT to build the WAR file for my Java web app. However,
I have problems connecting to CVS using ant build.xml. I figured out the reason
Currently I'm using a Windows batch file to build my software. It does things
I'm writing an ant build.xml file which does the following: Takes a zipped folder
I'm building a Java application (using Ant with build.xml and build.property files). Now I'd
I am facing problem while GWT compilation. I am using ANT build file in
I'm using ant to build my project, and use the 'svnversion' executable to insert
I'm using an Ant build script to collate my Eclipse-based application for distribution. One
I'm using Emma in my ant build to perform coverage reporting. For those that

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.