index.js
function determineLayers(json, version) {
	var layers = [];

	if (version == '1.3.0') {
		if (json.WMS_Capabilities.Capability) {
			if (json.WMS_Capabilities.Capability[0]) {
				if (json.WMS_Capabilities.Capability[0].Layer) {
					layers = buildLayers(json.WMS_Capabilities.Capability[0].Layer);
				}
			}
		}
	} else {
		if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') {
			if (json.WMT_MS_Capabilities.Capability) {
				if (json.WMT_MS_Capabilities.Capability[0]) {
					if (json.WMT_MS_Capabilities.Capability[0].Layer) {
						layers = buildLayers(json.WMT_MS_Capabilities.Capability[0].Layer);
					}
				}
			}
		}
	}
	return layers;
}
function determineLayers(json, version) {
	var layers = [];

	if (version == '1.3.0') {
		if (json.WMS_Capabilities.Capability) {
			if (json.WMS_Capabilities.Capability[0]) {
				if (json.WMS_Capabilities.Capability[0].Layer) {
					layers = buildLayers(json.WMS_Capabilities.Capability[0].Layer);
				}
			}
		}
	} else {
		if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') {
			if (json.WMT_MS_Capabilities.Capability) {
				if (json.WMT_MS_Capabilities.Capability[0]) {
					if (json.WMT_MS_Capabilities.Capability[0].Layer) {
						layers = buildLayers(json.WMT_MS_Capabilities.Capability[0].Layer);
					}
				}
			}
		}
	}
	return layers;
}
function determineLayers ( json , version ) { var layers = [ ] ; if ( version == '1.3.0' ) { if ( json . WMS_Capabilities . Capability ) { if ( json . WMS_Capabilities . Capability [ 0 ] ) { if ( json . WMS_Capabilities . Capability [ 0 ] . Layer ) { layers = buildLayers ( json . WMS_Capabilities . Capability [ 0 ] . Layer ) ; } } } } else { if ( version == '1.1.1' || version == '1.1.0' || version == '1.0.0' ) { if ( json . WMT_MS_Capabilities . Capability ) { if ( json . WMT_MS_Capabilities . Capability [ 0 ] ) { if ( json . WMT_MS_Capabilities . Capability [ 0 ] . Layer ) { layers = buildLayers ( json . WMT_MS_Capabilities . Capability [ 0 ] . Layer ) ; } } } } } return layers ; }
It determines the layer JSON from original XML GetCapabilities document.

@param json
{object} GetCapabilities document as JSON.
@param version
{string} Version of GetCapabilities document.
@returns {object} JSON object with layers from original XML GetCapabilities.
It determines the layer JSON from original XML GetCapabilities document .