Can you use Ant to build / modify XML files?

I am new to ant and am looking at tasks. I am trying to create an xml file. Do I need to access an external process or is there an ant way to do this? It can be as simple as sending a line to a txt file and saving it as .xml. Is it possible?

+5
source share
4 answers

The correct answer depends on what you are actually trying to do.

You can create a tiny XML document using the echo task and replacing the arguments, but this is difficult to handle very quickly.

, XML-, , , .

Ant ( ), xslt . XSLT , (XSLT , ).

Ant, , , , .

, , , - .

+5

XML ant, xmltask . . , , XPATH. = >

+10

Replace xml. , ant:

<replace file="${src}/index.html" token="@@@" value="wombat"/>

, @version@ java, .

, XSLT. , date - :

<xslt basedir="doc" destdir="build/doc"
      extension=".html" style="style/apache.xsl">
  <param name="date" expression="07-01-2000"/>
</xslt>
+4

You could do this, although it seems to me that it is more likely that you would like a script in advance, or something that you could call from Ant.

Task:

<echo file="my.xml"><!--put escaped xml here--></echo>

This, of course, will be tedious because everything needs to be avoided, but you can do it.

+1
source

All Articles