public WmsCapabilities(XDocument doc)
            : this()
        {
            if (doc.Root.Name == "ServiceExceptionReport")
            {
                ServiceExceptionReport = new ServiceExceptionReport(doc.Root, "");
                return;
            }

            var node = doc.Element(XName.Get("WMT_MS_Capabilities"));
            if (node == null) node = doc.Element(XName.Get("WMS_Capabilities"));
            if (node == null)
            {
                // try load root node with xmlns="http://www.opengis.net/wms"
                node = doc.Element(XName.Get("WMS_Capabilities", "http://www.opengis.net/wms"));
                if (node == null)
                {
                    throw WmsParsingException.ElementNotFound("WMS_Capabilities or WMT_MS_Capabilities");
                }
            }

            var att = node.Attribute(XName.Get("version"));
            if (att == null)
                throw WmsParsingException.AttributeNotFound("version");
            Version = new WmsVersion(att.Value);

            var @namespace = Version.Version == WmsVersionEnum.Version_1_3_0
                          ? "http://www.opengis.net/wms"
                          : string.Empty;
            XmlObject.Namespace = @namespace;

            att = node.Attribute("updateSequence");
            if (att != null)
                UpdateSequence = int.Parse(att.Value, NumberFormatInfo.InvariantInfo);

            var element = node.Element(XName.Get("Service", @namespace));
            if (element == null)
            {
                XmlObject.Namespace = @namespace = string.Empty;
                element = node.Element(XName.Get("Service", @namespace));
            }
            if (element == null)
                throw WmsParsingException.ElementNotFound("Service");

            Service = new Service(element, @namespace);

            element = node.Element(XName.Get("Capability", @namespace));

            if (element == null)
                throw WmsParsingException.ElementNotFound("Capability");

            Capability = new Capability(element, @namespace);
        }