Shell program to check if the same text appears twice in an XML file

Hi All,
I am very new to this forum and beginner to shell scripting.

I need a shell script to:

Search for a text in XML file � if the same text appears twice in an XML file � output file name
Script should loop thru every xml file of a given folder.

Please help me writing this script.

Thank you
Amar

#!/bin/bash
string="searchstring"
for file in *.xml
do
  if [ `grep -c $string $file` -gt 1 ]
  then
    echo $file
  fi
done

--ahamed