Share via


How to escape ampersands in command line strings and XML files

If you are using a command line app, and you have ampersands in any argument, you will get an error. To escape the ampersand, preface it with a carat (^).

Example: echo &bad_dog

Result: 'bad_dog' is not recognized as an internal or external command, operable program or batch file.

Fixed: echo ^&bad_dog
**
Ampersands in XML**

Similarly, if you are using an ampersand in an XML file, you also need to escape it using "&"

Example:

<add key ="sasToken" value ="sv=2015-02-21&tn"/>

Fixed:

<add key="sasToken" value ="sv=2015-02-21&tn"/>