Adding results of a find to an array

I'm trying to add the paths of all the xml files in certain directories to an array. I want to use the array later in my code. Anyway, for some reason this isn't working. Any help would be appreciated.

Path_Counter=0
for result in "find * -name '*.xml'"; do
  XmlPath[$Path_Counter]="$result"
  echo "$XmlPath[$Path_Counter]"
  let Path_Counter=Path_Counter+1
done

You're putting them in single and double quotes which treats it as a string, not backticks which would treat it as a command to run.

find * is redundant, find . will work, that tells it to search down starting from the current directory.

But I don't think you need a loop at all.

# for BASH shell
ARR=( `find . -name '*.xml'` )
# for KSH shell
set -A ARR `find . -name '*.xml' `

echo "ARR is ${#ARR[@]} elements"

If you only want files in the current directory it's even simpler:

# For BASH
ARR=( *.xml )
# for KSH
set -A ARR *.xml

But you should know there is a limit to the number of things you can store in an array. If this list could ever be larger than a few dozen you should think about ways to handle files one-by-one, or keeping the list in a temp file, instead of storing it all in memory.

Fully qualify the array by using ${XmlPath[$Path_Counter]} when you're echoing it out -- assignment looks OK. tldp explanation.