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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:07:56+00:00 2026-05-21T10:07:56+00:00

I am new to Ant. I am trying to determine whether an attribute is

  • 0

I am new to Ant. I am trying to determine whether an attribute is set or not in an xml file.
Below is the xml file I am dealing with [config.xml]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE LabelConfig
  SYSTEM "labelConfig.dtd">

<LabelConfig enabled="false">
</LabelConfig>

I want to check if above file (config.xml) has LabelConfig enabled or not, i.e I want to get and check the value of enabled attribute.

Here is what I’ve tried but is not full proof. I wrote below target

<target name="read_config">
    <loadfile property="msg" srcFile="d:/conf/config.xml" />
    <if>
        <or>
            <contains string="${msg}" substring="LabelConfig enabled='false'" />
            <contains string="${msg}" substring='LabelConfig enabled="false"' />
        </or>
        <then>
            <echo>LabelConfig is enabled</echo>
        </then>
        <else>
            <echo>LabelConfig is not enabled</echo>
        </else>
    </if>
</target>

This has a drawback of not working if multiple spaces occur in between attribute and tag.

Can anyone please guide me to a better way?

Thanks in advance,
Vaman

  • 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-21T10:07:56+00:00Added an answer on May 21, 2026 at 10:07 am

    Have a look at the xmlproperty task: http://ant.apache.org/manual/Tasks/xmlproperty.html

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

Sidebar

Related Questions

Hey, all. I'm currently trying to set up FTP support for my ANT (version
Let me preface by saying that I'm new to ant, and I'm using version
I am new to ant, but am trying to create an ant script that
I am new to using ANT and am trying to include third party jars
I'm using Ant 1.8, JUnit 4.8.2. I'm trying to load a properties file and
I am trying to update files inside an existing WAR file using the ANT
Every time I create a new project I copy the last project's ant file
I'm trying to execute in Java code analogue of Ant's updateDatabase task: Main.main( new
I'm trying to set up ANT for my Android project. According to the Android
I am new to Ant build script. I am trying to do following things

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.