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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:11:42+00:00 2026-05-25T18:11:42+00:00

I need to retrieve some values from an HTML file. I need to use

  • 0

I need to retrieve some values from an HTML file. I need to use Ant so I can use these values in other parts of my script.

Can this even be achieved in Ant?

  • 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-25T18:11:42+00:00Added an answer on May 25, 2026 at 6:11 pm

    As stated in the other answers you can’t do this in “pure” XML. You need to embed a programming language. My personal favourite is Groovy, it’s integration with ANT is excellent.

    Here’s a sample which retrieves the logo URL, from the groovy homepage:

    parse:
    
    print:
         [echo] 
         [echo]         Logo URL: http://groovy.codehaus.org/images/groovy-logo-medium.png
         [echo]     
    

    build.xml

    Build uses the ivy plug-in to retrieve all 3rd party dependencies.

    <project name="demo" default="print" xmlns:ivy="antlib:org.apache.ivy.ant">
    
        <target name="resolve">
            <ivy:resolve/>
            <ivy:cachepath pathid="build.path" conf="build"/>
        </target>
    
        <target name="parse" depends="resolve">
            <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
    
            <groovy>
            import org.htmlcleaner.*
    
            def address = 'http://groovy.codehaus.org/'
    
            // Clean any messy HTML
            def cleaner = new HtmlCleaner()
            def node = cleaner.clean(address.toURL())
    
            // Convert from HTML to XML
            def props = cleaner.getProperties()
            def serializer = new SimpleXmlSerializer(props)
            def xml = serializer.getXmlAsString(node)
    
            // Parse the XML into a document we can work with
            def page = new XmlSlurper(false,false).parseText(xml)
    
            // Retrieve the logo URL
            properties["logo"] = page.body.div[0].div[1].div[0].div[0].div[0].img.@src
            </groovy>
        </target>
    
        <target name="print" depends="parse">
            <echo>
            Logo URL: ${logo}
            </echo>
        </target>
    
    </project>
    

    The parsing logic is pure groovy programming. I love the way you can easily walk the page’s DOM tree:

    // Retrieve the logo URL
    properties["logo"] = page.body.div[0].div[1].div[0].div[0].div[0].img.@src
    

    ivy.xml

    Ivy is similar to Maven. It manages your dependencies on 3rd party software. Here it’s being used to pull down groovy and the HTMLCleaner library the groovy logic is using:

    <ivy-module version="2.0">
        <info organisation="org.myspotontheweb" module="demo"/>
        <configurations defaultconfmapping="build->default">
            <conf name="build" description="ANT tasks"/>
        </configurations>
        <dependencies>
            <dependency org="org.codehaus.groovy" name="groovy-all" rev="1.8.2"/>
            <dependency org="net.sourceforge.htmlcleaner" name="htmlcleaner" rev="2.2"/>
        </dependencies>
    </ivy-module>
    

    How to install ivy

    Ivy is a standard ANT plugin. Download it’s jar and place it in one of the following directories:

    $HOME/.ant/lib
    $ANT_HOME/lib
    

    I don’t know why the ANT project doesn’t ship with ivy.

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

Sidebar

Related Questions

I am maintaining a Python script that uses xlrd to retrieve values from Excel
Usually, I need to retrieve data from a table in some range; for example,
I have a dictionary/list balance_sign_dict from which I need to retrieve 2 values based
I like to retrieve and store the values of an HTML table from a
I want to retrieve some values from my url and post them in a
I'm trying to retrieve some most occurring values from a SQLite table containing a
I need to retrieve some data from a remote database, it is a kind
In several places I have to retrieve some value from a dict, but need
I need to retrieve all rows from a table where 2 columns combined are
I need to retrieve a record from a database, display it on a web

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.