'How to escape ampersand & in password in maven settings.xml

I have been given an ldap password which contains ampersand & . I am trying to use it in settings.xml and getting parsing issues. Till now I have tried

  1. replace & with &
  2. Replace password with <![CDATA[my&password]]>

Neither of these approaches worked. Can't pass it in command line as it is in too many places.

Any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source