public static List<string> getSpaceIds(XmlDocument xmldoc, XmlNamespaceManager xmlns, string searchpath)
        {
            List<string> spaceid = new List<string>();
            try
            {
                XmlNodeList nodes = xmldoc.SelectNodes(searchpath, xmlns);
                
                foreach (XmlNode spaceNode in nodes)
                {
                    //initialize a new instance of the class
                    gbXMLSpaces space = new gbXMLSpaces();
                    space.spacebounds = new List<SpaceBoundary>();
                    //get id and space
                    XmlAttributeCollection spaceAtts = spaceNode.Attributes;
                    foreach (XmlAttribute at in spaceAtts)
                    {
                        if (at.Name == "id")
                        {
                            space.id = at.Value;
                            spaceid.Add(at.Value);
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {

            }
            return spaceid;
        }
        public static List<gbXMLSpaces> getSimpleSpaces(XmlDocument xmldoc, XmlNamespaceManager xmlns)
        {
            List<gbXMLSpaces> retspaces = new List<gbXMLSpaces>();
            try
            {
                XmlNodeList nodes = xmldoc.SelectNodes("/gbXMLv5:gbXML/gbXMLv5:Campus/gbXMLv5:Building/gbXMLv5:Space", xmlns);

                foreach (XmlNode spaceNode in nodes)
                {
                    //initialize a new instance of the class
                    gbXMLSpaces space = new gbXMLSpaces();
                    space.spacebounds = new List<SpaceBoundary>();
                    //get id and space
                    XmlAttributeCollection spaceAtts = spaceNode.Attributes;
                    foreach (XmlAttribute at in spaceAtts)
                    {
                        if (at.Name == "id")
                        {
                            space.id = at.Value;
                            break;
                        }
                    }
                    if (spaceNode.HasChildNodes)
                    {
                        XmlNodeList childNodes = spaceNode.ChildNodes;
                        foreach (XmlNode node in childNodes)
                        {
                            if (node.Name == "PlanarGeometry")
                            {
                                space.pg = new PlanarGeometry();
                                XmlNodeList childnodes = node.ChildNodes;
                                foreach (XmlNode node2 in childnodes)
                                {
                                    if (node2.Name == "PolyLoop")
                                    {
                                        space.pg.pl = new PolyLoop();
                                        space.pg.pl.plcoords = new List<Vector.MemorySafe_CartCoord>();

                                        XmlNodeList cartPoints = node2.ChildNodes;
                                        foreach (XmlNode point in cartPoints)
                                        {
                                            if (point.Name == "CartesianPoint")
                                            {
                                                Vector.CartCoord coord = new Vector.CartCoord();
                                                XmlNodeList val = point.ChildNodes;
                                                int pointcount = 1;
                                                foreach (XmlNode cpoint in val)
                                                {
                                                    switch (pointcount)
                                                    {
                                                        case 1:
                                                            coord.X = Convert.ToDouble(cpoint.InnerText);
                                                            break;
                                                        case 2:
                                                            coord.Y = Convert.ToDouble(cpoint.InnerText);
                                                            break;
                                                        case 3:
                                                            coord.Z = Convert.ToDouble(cpoint.InnerText);
                                                            break;
                                                    }
                                                    pointcount++;
                                                }
                                                Vector.MemorySafe_CartCoord memsafecoord = Vector.convertToMemorySafeCoord(coord);
                                                space.pg.pl.plcoords.Add(memsafecoord);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (node.Name == "ShellGeometry")
                            {
                                space.sg = new ShellGeometry();
                                XmlAttributeCollection sgAtts = spaceNode.Attributes;
                                foreach (XmlAttribute at in sgAtts)
                                {
                                    if (at.Name == "id")
                                    {
                                        space.sg.id = at.Value;
                                        break;
                                    }
                                }

                                XmlNodeList childnodes = node.ChildNodes;
                                foreach (XmlNode sgnode in childnodes)
                                {
                                    if (sgnode.Name == "ClosedShell")
                                    {
                                        space.sg.cs = new ClosedShell();
                                        space.sg.cs.ploops = new List<PolyLoop>();

                                        foreach (XmlNode pl in sgnode)
                                        {
                                            if (pl.Name == "PolyLoop")
                                            {
                                                PolyLoop sgpl = new PolyLoop();
                                                sgpl.plcoords = new List<Vector.MemorySafe_CartCoord>();
                                                XmlNodeList cartPoints = pl.ChildNodes;
                                                foreach (XmlNode point in cartPoints)
                                                {
                                                    if (point.Name == "CartesianPoint")
                                                    {
                                                        Vector.CartCoord coord = new Vector.CartCoord();
                                                        XmlNodeList val = point.ChildNodes;
                                                        int pointcount = 1;
                                                        foreach (XmlNode cpoint in val)
                                                        {
                                                            switch (pointcount)
                                                            {
                                                                case 1:
                                                                    coord.X = Convert.ToDouble(cpoint.InnerText);
                                                                    break;
                                                                case 2:
                                                                    coord.Y = Convert.ToDouble(cpoint.InnerText);
                                                                    break;
                                                                case 3:
                                                                    coord.Z = Convert.ToDouble(cpoint.InnerText);
                                                                    break;
                                                            }
                                                            pointcount++;
                                                        }
                                                        Vector.MemorySafe_CartCoord memsafecoord = Vector.convertToMemorySafeCoord(coord);
                                                        sgpl.plcoords.Add(memsafecoord);
                                                    }
                                                }
                                                space.sg.cs.ploops.Add(sgpl);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (node.Name == "SpaceBoundary")
                            {
                                SpaceBoundary sb = new SpaceBoundary();
                                XmlAttributeCollection spbatts = node.Attributes;
                                foreach (XmlAttribute at in spbatts)
                                {
                                    if (at.Name == "surfaceIdRef")
                                    {
                                        sb.surfaceIdRef = at.Value;
                                        break;
                                    }
                                }
                                XmlNodeList sbchilds = node.ChildNodes;
                                foreach (XmlNode sbpnode in sbchilds)
                                {
                                    if (sbpnode.Name == "PlanarGeometry")
                                    {
                                        sb.sbplane = new PlanarGeometry();
                                        XmlNodeList pgchilds = sbpnode.ChildNodes;
                                        foreach (XmlNode pgchild in pgchilds)
                                        {
                                            if (pgchild.Name == "PolyLoop")
                                            {
                                                sb.sbplane.pl = new PolyLoop();

                                                sb.sbplane.pl.plcoords = new List<Vector.MemorySafe_CartCoord>();
                                                XmlNodeList cartPoints = pgchild.ChildNodes;
                                                foreach (XmlNode point in cartPoints)
                                                {
                                                    if (point.Name == "CartesianPoint")
                                                    {
                                                        Vector.CartCoord coord = new Vector.CartCoord();
                                                        XmlNodeList val = point.ChildNodes;
                                                        int pointcount = 1;
                                                        foreach (XmlNode cpoint in val)
                                                        {
                                                            switch (pointcount)
                                                            {
                                                                case 1:
                                                                    coord.X = Convert.ToDouble(cpoint.InnerText);
                                                                    break;
                                                                case 2:
                                                                    coord.Y = Convert.ToDouble(cpoint.InnerText);
                                                                    break;
                                                                case 3:
                                                                    coord.Z = Convert.ToDouble(cpoint.InnerText);
                                                                    break;
                                                            }
                                                            pointcount++;
                                                        }
                                                        Vector.MemorySafe_CartCoord memsafecoord = Vector.convertToMemorySafeCoord(coord);
                                                        sb.sbplane.pl.plcoords.Add(memsafecoord);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                //finally, add the thing here
                                space.spacebounds.Add(sb);
                            }
                        }
                    }
                    else
                    {
                        //throw something
                    }
                    retspaces.Add(space);
                }
            }
            catch (Exception e)
            {

            }
            return retspaces;
        }