If you have a list of craft names you can loop through the list, set them as target, and check the distance to target in order to get a list of nearby craft. You could add new craft to that list whenever the player manually sets the target to something new. There is no way to automatically detect new craft that you don't know the name of.
I'm not sure why you would need to muck with the XML unless you are trying to modify a running program in an active craft, which I suppose would be doable if you prefer stopping the game and modifying XML as a way to add new craft to your list.
If you have a list of craft names you can loop through the list, set them as target, and check the distance to target in order to get a list of nearby craft. You could add new craft to that list whenever the player manually sets the target to something new. There is no way to automatically detect new craft that you don't know the name of.
I'm not sure why you would need to muck with the XML unless you are trying to modify a running program in an active craft, which I suppose would be doable if you prefer stopping the game and modifying XML as a way to add new craft to your list.