Search code examples
xmlantxmltask

How do I escape '&' in a property for use with xmltask?


I've got a property string (loaded from a file) containing the ampersand character in my ANT build-script.

How can I escape that string so I can write it to a xml-file using xmltask?

EDIT: The following code works but I can't replace &amp with &amp so I have to use the word 'and':

      <propertyregex property="prop"
           input="${prop}"
           regexp="&amp;"
           replace="and"
           override="true"
           global="true" />

Solution

  • Try either :
    &amp;amp; which is parsed to &amp; which in turn results in &
    or HTML Entity (decimal) &#38;
    or HTML Entity (hex) &#x26;