String tileWidthString = getAttributeValue(mapNode, "tilewidth"); String tileHeightString = getAttributeValue(mapNode, "tileheight");
int tileWidth = getAttribute(mapNode, "tilewidth", 0); int tileHeight = getAttribute(mapNode, "tileheight", 0);
    private void buildMap(Document doc) throws Exception {        Node item,mapNode;        NodeList l,mapNodeList;        NamedNodeMap nnm;        Tile tile;        mapNodeList = doc.getElementsByTagName("map");        for (int itr = 0; (mapNode = mapNodeList.item(itr)) != null; itr++) {            // Get the map dimensions and create the map            l = doc.getElementsByTagName("dimensions");            for (int i = 0; (item = l.item(i)) != null; i++) {                if (item.getParentNode() == mapNode) {                    int mapWidth =                        Integer.parseInt(getAttributeValue(item, "width"));                    int mapHeight =                        Integer.parseInt(getAttributeValue(item, "height"));                    map = new Map(mapWidth, mapHeight);                }            }            if (map == null) {                throw new Exception("Couldn't locate map dimensions.");            }            // Load other map attributes            map.setName(getAttributeValue(mapNode,"name"));            String orientation = getAttributeValue(mapNode, "orientation");            String tileWidthString = getAttributeValue(mapNode, "tilewidth");            String tileHeightString = getAttributeValue(mapNode, "tileheight");            if (tileWidthString != null) {                map.setTileWidth(Integer.parseInt(tileWidthString));            }            if (tileHeightString != null) {                map.setTileHeight(Integer.parseInt(tileHeightString));            }            if (orientation != null) {                setOrientation(orientation);            } else {                throw new Exception("A valid orientation must be given");            }            // Load the properties            l = doc.getElementsByTagName("property");			for (int i = 0; (item = l.item(i)) != null; i++) {				if(item.getParentNode() == mapNode) {                   	                map.addProperty(getAttributeValue(item, "name"),	                        getAttributeValue(item, "value"));				}            }            // Load the tile sets            l = doc.getElementsByTagName("tileset");            for (int i = 0; (item = l.item(i)) != null; i++) {                if (item.getParentNode() == mapNode) {                    map.addTileset(unmarshalTileset(item));                }            }            // Load the layers            l = doc.getElementsByTagName("layer");            for (int i = 0; (item = l.item(i)) != null; i++) {                if (item.getParentNode() == mapNode) {                    map.addLayer(unmarshalLayer(item));                }            }			//Load the objects			l = doc.getElementsByTagName("object");			for (int i = 0; (item = l.item(i)) != null; i++) {				if (item.getParentNode() == mapNode) {					map.addObject(unmarshalObject(item));				}			}        }    }