# How to add a header to xml file

**URL:** <https://www.ruby-forum.com/t/how-to-add-a-header-to-xml-file/172903>\
**Category:** Ruby\
**Created:** [July 29, 2009, 6:19pm UTC](https://www.ruby-forum.com/t/how-to-add-a-header-to-xml-file/172903 "2009-07-29T18:19:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/4bbf92/32.png) [@bali](https://www.ruby-forum.com/u/bali)\
**Post date:** [July 29, 2009, 6:19pm UTC](https://www.ruby-forum.com/t/how-to-add-a-header-to-xml-file/172903/1 "2009-07-29T18:19:12Z")

</div>

I have a ant build file:

it needs to be changed to:

\<?xml version="1.0" encoding="UTF-8" ?\> 
## After processed, ant complains:

D:\googlecode\balionweb\test\>ant compile  
Buildfile: build.xml

BUILD FAILED  
D:\googlecode\balionweb\test\build.xml:12: Content is not allowed in  
prolog.

## Total time: 0 seconds

I have problem in handling new line. Tried “\r”, “\n” and “\r\n”, but no  
luck.  
It looks like the first line of xml file is pretty special.

How to do this? Better provide a working code.

Thanks.

---

<div class="post-metadata">

**Author:** ![bali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/4bbf92/32.png) [@bali](https://www.ruby-forum.com/u/bali)\
**Post date:** [July 29, 2009, 10:54pm UTC](https://www.ruby-forum.com/t/how-to-add-a-header-to-xml-file/172903/2 "2009-07-29T22:54:37Z")

</div>

On Jul 29, 2009, at 09:19, Bali Bali wrote:

> I have a ant build file:
> 
> […]
> 
> After processed, ant complains:

> […]

Try an ant mailing list?
