The answer from Joey was not working for me. After executing
echo ^<?xml version="1.0" encoding="utf-8" ?^> > myfile.xml
I got this error bash: syntax error near unexpected token `>'
This solution worked for me:
echo "<?xml version=\"1.0\" encoding=\"utf-8\">" > myfile.txt