How to achieve UTF-8 encoding & URL escape in an xml file?

Is there any i can achieve entity escaping, URL escaping & UTF-8 encoded for the xml generated through shell script?

      #! /bin/bash
      echo "<path>" >> file.xml
      for x in `ls filename*`
      do
      echo -e "\t<dir>" >> file.xml
      echo -e "\t\t<file>$x</file>" >> file.xml
      echo -e "\t<dir>" >> file.xml
      done
      echo "</path>" >> file.xml