Search code examples
xmlantreplacexml-declaration

ANT - replace xml declaration


I have an XML document composed of several other XML documents appended to it. As a result, there are several XML declarations within the document which prevent my XSLT from parsing it correctly. I am trying to remove the declarations from the document using the ant replace and replaceregexp tasks, but they do nothing to the file. This is what I have so far.

<replaceregexp file="${cppUnit.file}" >
    <regexp pattern="&lt;?xml * ?&gt;" />
    <substitution expression="" />
</replaceregexp>

Solution

  • Try this instead:

    <replaceregexp file="${cppUnit.file}" match="&lt;\?xml.*\?&gt;"
         replace="" byline="true"/>