Accessing maps and layers via the MapDocument
The MapDocument class is a utility class for reading and modifying map documents (.mxds).  This document demonstrates how to open a map document and loop through all its maps and layers. In this example, the names of these objects are reported to the console. See the following:
    [Java]
        
static void openMXDViaMapDocument(String path)throws Exception{
    IMapDocument mapDoc = new MapDocument();
    if (mapDoc.isMapDocument(path)){
        mapDoc.open(path, null);
        IMap map;
        for (int i = 0; i <= mapDoc.getMapCount() - 1; i++){
            map = mapDoc.getMap(i);
            System.out.println(map.getName());
            IEnumLayer enumLayers = map.getLayers(null, true);
            enumLayers.reset();
            ILayer layer = enumLayers.next();
            while (layer != null){
                System.out.println(layer.getName());
                layer = enumLayers.next();
            }
        }
    }
}
      | Development licensing | Deployment licensing | 
|---|---|
| ArcGIS for Desktop Basic | ArcGIS for Desktop Basic | 
| ArcGIS for Desktop Standard | ArcGIS for Desktop Standard | 
| ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced | 
| Engine Developer Kit | Engine |