/// <summary>
        /// Initializes a new KML <c>&lt;Document&gt;</c> element.
        /// </summary>
        /// <param name="xml">The XML element the document should be based on.</param>
        /// <param name="namespaces">The XML namespace.</param>
        protected KmlDocument(XElement xml, XmlNamespaceManager namespaces) : base(xml, namespaces)
        {
            NetworkLink = xml.GetElement("kml:NetworkLink", namespaces, KmlNetworkLink.Parse);

            List <KmlStyleSelector> selectors = new List <KmlStyleSelector>();

            List <KmlFeature> features = new List <KmlFeature>();

            foreach (XElement child in xml.Elements())
            {
                switch (child.Name.LocalName)
                {
                case "Style":
                    selectors.Add(KmlStyle.Parse(child, namespaces));
                    break;

                case "StyleMap":
                    selectors.Add(KmlStyleMap.Parse(child, namespaces));
                    break;

                case "Document":
                    features.Add(KmlDocument.Parse(child, namespaces));
                    break;

                case "Folder":
                    features.Add(KmlFolder.Parse(child, namespaces));
                    break;

                case "NetworkLink":
                    features.Add(KmlNetworkLink.Parse(child, namespaces));
                    break;

                case "Placemark":
                    features.Add(KmlPlacemark.Parse(child, namespaces));
                    break;

                case "GroundOverlay":
                case "PhotoOverlay":
                case "ScreenOverlay":
                    // currently not supported
                    break;
                }
            }

            StyleSelectors = new KmlStyleSelectorCollection(selectors);
            Features       = new KmlFeatureCollection(features);
        }
        public static KmlFeatureCollection GetFromChildren(XElement xml)
        {
            List <KmlFeature> temp = new List <KmlFeature>();

            foreach (XElement element in xml.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "Placemark":
                    temp.Add(KmlPlacemark.Parse(element));
                    break;

                case "Folder":
                    temp.Add(KmlFolder.Parse(element));
                    break;

                case "Document":
                    temp.Add(KmlDocument.Parse(element));
                    break;
                }
            }

            return(temp.ToArray());
        }