This question already has an answer here:
- Concatenate xml file in ant script 2 answers
I am concatenating all the xml files in a folder into a single xml file in ant script. While concatenating the xml files, the header
<?xml version="1.0" encoding="UTF-8" ?>
in all xml files are getting appended in the output xmlfile.
Is there any way to avoid this header ?
<concat destfile="${docbook.dir}/all-sections.xml"
force="no">
<fileset dir="${docbook.dir}"
includes="sections/*.xml"/>
</concat>
You can apply a regex to discard the header:
https://ant.apache.org/manual/Types/filterchain.html
EDIT: If you want to keep the first occurrence of the header then this is an option:
There is a filter chain.So you can use ' xml version' or 'encoding' to filter.
Then there is one Header that can be added as common.There you can give the common header.
Function Ref: https://googleweblight.com/?lite_url=https://ant.apache.org/manual/Tasks/concat.html&ei=t1jfBWPU&lc=en-IN&s=1&m=717&host=www.google.co.in&ts=1456774849&sig=ALL1Aj6a3WOuua261FfWU1a1B-ULkTgOMw