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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:25:50+00:00 2026-05-24T19:25:50+00:00

I have directory with subdirs with xml files in it with different extensions. Start

  • 0

I have directory with subdirs with xml files in it with different extensions.


Start of updated part


Target dir: /some/path

Target files mask: *.load

Basic filterset we use to find *.load files under /some/path:

<fileset dir="/some/path">
    <include name="**/*.load" />
</fileset>

There could by multiple subdirs under /some/path and multiple *.load files also.

But we need to enhance filtering based on XML content and params described in examples, use cases below.

Examples:

load_file1.load:

<load 
    id="0a0740d1fc1a33a28f1397b76cae48bc"
    order="9"
    enable="true"
    name="Load name 1"
    type="LoadType.custom">
    <parent />
    <default-property name="Property2"
                      type="java.lang.Integer"
                      value="0" />
    <default-property name="Property1"
                      type="java.lang.Boolean"
                      value="false" />
</load>

load_file2.load:

<load 
      id="ec9ca08d11ca34b42e13c5f21578d82c"
      name="Load name 2"
      order="0"
      enable="true"
      type="LoadType.base">
    <parent />
    <default-property name="Load name 1"
                      type="java.lang.String"
                      value="test3" />
    <default-property name="Property2"
                      type="java.lang.Integer"
                      value="0" />
    <!-- here could be any number of other sub-properties  -->
    <date-range end-date="1/31/1900"
                     start-date="1/31/1900" />
</load>

Input data:

Ant param: Load_name = "Load name 1" – used to find corresponding files

Ant param: Load_param_name_replace = "enable"

Ant param: Load_param_value_replace = "false"

NB! We always search for files based on value of //load/@name attribute (hardcoded) inside them:

<load 
      id="ec9ca08d11ca34b42e13c5f21578d82c"
      name="Load name 2"
      order="0"
      enable="true"
      type="LoadType.base">

Problem (based on example of files above):

  1. We should find files where //load/@name = $Load_name ANT param (“Load name 1“)

  2. We should change in found files (could be multiple) XML attribute declared in $Load_param_name_replace ANT param (“enable“) value to value of ANT param $Load_param_value_replace (“false“)

Expected results:

  1. File(s) is found: load_file1.load

NB! please pay attention that in load_file2.load we have <default-property name="Load name 1" ... that match combination name="Load name 1", but we need to distinguish between this invalid case and valid one in file load_file1.load.

  1. In found file(s) load_file1.load XML attribute defined in $Load_param_name_replace (“enable“) ANT param under //load node should be changed to new value defined in ANT param $Load_param_value_replace (“false“)

So after ANT task the file load_file1.load should look as:

<load 
    id="0a0740d1fc1a33a28f1397b76cae48bc"
    order="9"
    enable="false"
    name="Load name 1"
    type="LoadType.custom">
    <parent />
    <default-property name="Property2"
                      type="java.lang.Integer"
                      value="0" />
    <default-property name="Property1"
                      type="java.lang.Boolean"
                      value="false" />
</load>

End of updated part


As you can see xml files content is spread through multiple lines – that is the tricky part for me.

We tried ANT fileset target with containsregexp filters where searched for multiline regex with name="load_name1" but without success. We used multiline=true and singleline=true – didnt work either.

After that we tried XMLtask – but there were not enough examples of how to replace xml property in multiple .XML files based on some fileset.

So if you could provide a couple of examples – it’d be greatful!

  • 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-24T19:25:51+00:00Added an answer on May 24, 2026 at 7:25 pm

    Completely revised after updated problem description :

    <project>
    <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
    
    <property name="editno" value='&lt;default-property name="Load name 1"'/>
    <property name="edityes" value='name="Load name 1"'/>
    <property name="editxpath" value="//load/@enable"/>
    <property name="editnew" value="false"/>
    
     <xmltask todir="/some/path" report="true">
      <fileset dir="/some/path">
       <include name="**/*.load"/>
        <not>
         <contains text="${editno}" casesensitive="true"/>
        </not>
        <contains text="${edityes}" casesensitive="true"/>
       </fileset>
       <replace path="${editxpath}" withText="${editnew}"/>
      </xmltask>
    </project>
    

    for a quick check of the contents of a fileset simply use the builtin property ${toString:filesetid}

     <fileset dir="/some/path" id="foobar">
      <include name="**/*.load" />
      <not>
       <contains text="${editno}" casesensitive="true" />
      </not>
      <contains text="${edityes}" casesensitive="true" />
     </fileset>
    
     <echo>${toString:foobar}</echo>
    

    see Ant manual Properties and PropertyHelpers

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

Sidebar

Related Questions

I have directory with > 1000 .html files, and would like to check all
I have directory A with files matching directory B. Directory A may have other
let's say i have directory paths looking like this: this/is/the/basedir/path/a/include this/is/the/basedir/path/b/include this/is/the/basedir/path/a this/is/the/basedir/path/b In
I have a directory with PDF files that I need to create an index
I have a directory with several subdirectories with files. How can I copy all
I have a directory full of files and I need to pull the headers
I have a directory of files that I'd like to append file extension to
I have an directory, which has a lot of subdirectories. those subdirs sometimes even
I have a directory structure that looks like this: basedir/dir1/dir2/dir3/dir4/myzip/subdirs I would like to
I have written a function which scans all the files/directory in a given directory

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.