Carriage returns in XML comment: "The content of elements must consist of well-formed character data or markup"

Epaga picture Epaga · Feb 10, 2011 · Viewed 12.2k times · Source

I have the following Ant build file:

<?xml version="1.0" encoding="UTF-8"?>
<project default="build" name="MyAntScript">

    <!--
    A comment explaining
    the ant file going over
    multiple lines
    like this
    quite poetic, huh?
    -->

    <import file="myant.xml" />
    ...
</project>

When viewing this file in Eclipse and when running my Ant script, it gives me the following error message

      c:\myant.xml:6: The content of elements must consist of well-formed
      character data or markup.

The error goes away if I turn the XML comment into a single line (edit: and comes back when I put the newline back in...). What gives??


Edit The problem was in the imported ant file..Eclipse had an issue where it marked line 6 in the main Ant build file rather than the imported build file.

Answer

Epaga picture Epaga · Feb 10, 2011

Thanks to Jon Skeet's pointers, I tried shortening the Ant file until I figured out the problem was actually in line six of an imported Ant build file, not the main file itself. This had thrown me off since Eclipse was marking line six of the main Ant build file.

The imported Ant build file had a SVN conflict which obviously led to issues with XML well-formedness.

Sorry about that. I'll leave this open in case someone else encounters a similar silly mistake...