Use the regex end-anchor (`$`), e.g.:
echo "$file" | grep '\.xml$'
To find all files ending with "xml", I would suggest using the `find` command, e.g.:
find . -name '*.xml'
Would recursively list all xml files from current directory.