I understand from the comments that the OP likes the output from the linked code but would like the information placed into an xml file that can be queried.
Her'es how to modify the script given at Get contents of .desktop files to process the output into an XML file.
filename="MyDesktopFiles.xml"
rm $filename
touch $filename
echo '<?xml version="1.0"?>' >> $filename
echo '<items>' >> $filename
for files in /usr/share/applications/*.desktop;
do
echo '<item>' >> $filename
echo ' <name>'$(grep -e "^Name=" $files | sed 's/Name=//g')'</name>' >> $filename
echo ' <command>'$(grep -e "^Exec=" $files | sed 's/Exec=//g')'</command>' >> $filename
echo '</item>' >> $filename
done
echo '</items>' >> $filename
echo '</xml>' >> $filename