Exemplo n.º 1
0
        private AstroObjectResult ParseXml(string data)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(data);

                AstroObjectResult[] list = new AstroObjectResult[1];
                list[0] = new AstroObjectResult();

                XmlNode root     = doc["Sesame"];
                XmlNode resolver = root.SelectSingleNode("Target/Resolver");
                foreach (XmlNode child in resolver.ChildNodes)
                {
                    switch (child.Name)
                    {
                    case "jradeg":
                        list[0].RA = Convert.ToDouble(child.InnerText) / 360 * 24;
                        break;

                    case "jdedeg":
                        list[0].Dec = Convert.ToDouble(child.InnerText);
                        break;

                    case "oname":
                        list[0].Name = child.InnerText;
                        break;
                    }
                }
                if (list[0].RA == 0 && list[0].Dec == 0)
                {
                    return(null);
                }

                return(list[0]);
            }
            catch
            {
                return(null);
            }
        }
        private AstroObjectResult ParseXml(string data)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(data);

                AstroObjectResult[] list = new AstroObjectResult[1];
                list[0] = new AstroObjectResult();

                XmlNode root = doc["Sesame"];
                XmlNode resolver = root.SelectSingleNode("Target/Resolver");
                foreach (XmlNode child in resolver.ChildNodes)
                {
                    switch (child.Name)
                    {
                        case "jradeg":
                            list[0].RA = Convert.ToDouble(child.InnerText) / 360 * 24;
                            break;
                        case "jdedeg":
                            list[0].Dec = Convert.ToDouble(child.InnerText);
                            break;
                        case "oname":
                            list[0].Name = child.InnerText;
                            break;
                    }
                }
                if (list[0].RA == 0 && list[0].Dec == 0)
                {
                    return null;
                }

                return list[0];
            }
            catch
            {
                return null;
            }
        }