/**
  * This method parses a given XML string and returns a DataObjectSet.
  * This implementation parses a xml schema (i.e. dublin core, iso19139)
  * and retrieves just the title and all subjects of each result entry.
  *
  * The dublin-core metadata schema is embedded into a CSW-metadata
  * envelope (@link http://www.opengis.net/cat/csw/2.0.2).
  *
  * @param string $responseXML valid OGC XML response string
  * @param string $xsl SilverStripe XSLT to transform the XML response into the internal data structure.
  *
  * @return ViewableData
  */
 public function parseXML($responseXML)
 {
     $responseXML = str_replace("'", "\\'", $responseXML);
     // parsing
     $doc = new DOMDocument();
     $doc->loadXML($responseXML);
     list($numberOfRecordsMatched, $numberOfRecordsReturned, $nextRecord, $mdArray) = $this->parseDocument($doc);
     $result = new ViewableData();
     $resultItems = new ArrayList();
     foreach ($mdArray as $item) {
         $metadata = new MDMetadata();
         if (isset($item['dateTimeStamp']) && $item['dateTimeStamp']) {
             $item['dateStamp'] = $item['dateTimeStamp'];
         }
         $metadata->update($item);
         $metadata->loadData($item);
         // print_r($metadata);die();
         $resultItems->push($metadata);
     }
     //To avoid unset variables due the xslt
     if (!isset($nextRecord)) {
         $nextRecord = 1;
     }
     if (!isset($timestamp)) {
         $timestamp = null;
     }
     if (!isset($numberOfRecordsMatched)) {
         $numberOfRecordsMatched = 1;
     }
     if (!isset($numberOfRecordsReturned)) {
         $numberOfRecordsReturned = 1;
     }
     $result = $result->customise(array('Items' => $resultItems, 'timestamp' => $timestamp, 'nextRecord' => $nextRecord, 'numberOfRecordsMatched' => $numberOfRecordsMatched, 'numberOfRecordsReturned' => $numberOfRecordsReturned));
     return $result;
 }