I can understand what the contents are, but I am at a loss to see how the XML file is associated with the web page containing the gallery.
The web page containing the gallery will contain the gallery's embedding code (as found here).
You would use a configUrl within the embedding code to point towards your PHP file so that Juicebox can find it, e.g.:
<!--START JUICEBOX EMBED-->
<script src="jbcore/juicebox.js"></script>
<script>
new juicebox({
configUrl: 'path_to_php_file/config.php',
containerId: "juicebox-container",
galleryWidth: "100%",
galleryHeight: "100%",
backgroundColor: "#222222"
});
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->
Will I have to generate a different XML file for every gallery used
The XML file is where the list of images and captions is stored. Therefore, each gallery needs its own XML file (otherwise all galleries would display the same images and captions).
However, you could use the same PHP file to generate the XML data for different galleries by adding query string parameters to your configUrl to differentiate between galleries and so that the PHP file knows which gallery's information to gather, e.g.:
configUrl: 'path_to_php_file/config.php?id=12',
In the example above, you would get the 'id' within the PHP file (using $_GET['id']) and the PHP file would conditionally gather information from your chosen source depending on this value.
I think I better download "JuiceBox" and look at the code, to see how it all links together
This would be a good idea. The principle is the same for Juicebox-Lite as it is for Juicebox-Pro so download Juicebox-Lite and try it out for yourself.
most of your documentation, seems to be about generating a gallery in a directory
A gallery's files are usually all stored in the same directory for ease of use. Your gallery's files do not all need to be in the same directory but if you move them, then you may need to point towards them using configuration options such as configUrl, baseUrl and themeUrl. A list of these Embed Options can be found here.
the images that make up my gallery can come from different directories.
The images and thumbnails for the gallery can be anywhere on your web server and they are pointed to via the imageURL and thumbURL entries in the XML file (which would need to be determined by your PHP file).
This FAQ (and the links within it) may also help:
Can Juicebox handle a custom data source, for example RSS or Instagram?