Index: branches/pap/ippToPsps/src/ippToPsps.c
===================================================================
--- branches/pap/ippToPsps/src/ippToPsps.c	(revision 28498)
+++ branches/pap/ippToPsps/src/ippToPsps.c	(revision 28534)
@@ -53,4 +53,14 @@
     }
 
+    // save XML document for results
+    if (this->resultsXmlDoc) {
+    
+        xmlSaveFormatFileEnc(this->resultsPath, this->resultsXmlDoc, "UTF-8", 1);
+
+        xmlFreeDoc(this->resultsXmlDoc);
+        xmlCleanupParser();
+        xmlMemoryDump();
+    }
+
     psFree(this->fitsInPath);
     psFree(this->resultsPath);
@@ -59,5 +69,4 @@
     psFree(this->pmconfig);
 
-    if (this->resultsFile) fclose(this->resultsFile);
 
     for(uint32_t i=0; i<this->numOfInputFiles; i++)
@@ -246,5 +255,5 @@
     this->fitsInPath = NULL;
     this->resultsPath = NULL;
-    this->resultsFile = NULL;
+    this->resultsXmlDoc = NULL;
     this->numOfInputFiles = 0;
     this->inputFiles = NULL;
@@ -304,4 +313,5 @@
     }
 
+    // create a config object
     this->config = ippToPspsConfig_Constructor(this->configsDir);
     if (this->config == NULL) {
@@ -311,18 +321,11 @@
     }
 
-    // ready results file, if necessary
+    // create XML document for results 
     if (this->resultsPath) {
 
-        this->resultsFile = fopen (this->resultsPath, "w+");
-
-        if (this->resultsFile == NULL) {
-
-            psError(PS_ERR_UNKNOWN, false, "Unable to open results file at %s", this->resultsPath);
-            // not essential to write results, so don't bail out
-        }
-        else {
-            if (fprintf(this->resultsFile, "%s\n", outputName) < 1 )     
-                psError(PS_ERR_IO, false, "Unable to write FITS output filename to'%s'\n", this->resultsPath);
-        }
+        this->resultsXmlDoc = xmlNewDoc(BAD_CAST "1.0");
+        xmlNodePtr rootNode = xmlNewNode(NULL, BAD_CAST "ippToPsps_Results");
+        xmlDocSetRootElement(this->resultsXmlDoc, rootNode);
+        xmlNewChild(rootNode, NULL, BAD_CAST "filename", BAD_CAST outputName);
     }
 
