I have xml files been imported onto an FTP server. This is stored in location \'/public_html/ctrackxml/\' with a random file name and in the following format:
Browsing your code it looks like the following:
foreach ($message->message as $message) {
should actually be:
foreach ($library->message as $message) {
$library contains your XML object so it should be the one you are accessing and not the, as yet, unitialised $message variable.
Were $message initialised your current code would actually wipe itself out with each iteration of the for loop because it assigns its child element to itself!