EnumerateResources($rootId, -1, 'MapDefinition'); //make a list of maps to query for names $mapListXml = new DOMDocument(); $mapListXml->loadXML(ByteReaderToString($maps)); //$aMapAssoc = Array(); $aMapIds = $mapListXml->getElementsByTagName('ResourceId'); //iterate over mapIds to retrieve names //output map list as JSON $result = NULL; $result->maps = array(); for ( $i=0; $i < $aMapIds->length; $i++ ) { $mapId = new MgResourceIdentifier($aMapIds->item($i)->nodeValue); $md = NULL; $md->path = $aMapIds->item($i)->nodeValue; $md->name = $mapId->GetName(); array_push($result->maps, $md); } header('Content-type: application/json'); echo var2json($result); exit; function ByteReaderToString($byteReader) { $buffer = ''; do { $data = str_pad("\0", 50000, "\0"); $len = $byteReader->Read($data, 50000); if ($len > 0) { $buffer = $buffer . substr($data, 0, $len); } } while ($len > 0); return $buffer; } ?>