"Dynamic" XML photo gallery, mp3 player?

Is there a way to create an XML-based photo gallery that can go and “find” image files in a given directory – meaning, figure out how many there are and the file names on the fly – so that I don’t have to provide file names in a hard-coded fashion?

Also, as an extension to that question, I have been curious if it’s possible to extend that kind of functionality for an AS3 mp3 player that will look in a given directory and discover a new song, add it to the player’s play list, and make it available to listen to.

If so, I’m not necessarily asking to provide the code, just a link if there is one.

Many thanks!