获取手机号码所在地

请直接看代码:
private  static string[] GetMobileInfo(string number)
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load("http://api.showji.com/Locating/default.aspx?m=" + number);
                XmlNamespaceManager cx = new XmlNamespaceManager(xmlDocument.NameTable);
                cx.AddNamespace("content""http://api.showji.com/Locating/");
                XmlNodeList nodes = xmlDocument.SelectNodes("//content:QueryResult|//content:Mobile|//content:Province|//content:City|//content:Corp|//content:Card|//content:AreaCode|//content:PostCode", cx);
                if (nodes.Count == 8)
                {
                    if ("True".Equals(nodes[1].InnerText))
                    {
                        return new string[]
                                   {
                                       nodes[0].InnerText, nodes[2].InnerText, nodes[3].InnerText, nodes[4].InnerText,
                                       nodes[5].InnerText, nodes[6].InnerText + nodes[7].InnerText
                                   };
                    }
                }
                return new string[] { "false" };
            }
            catch (Exception)
            {
                return new string[] { "false" };
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string[] num = GetMobileInfo(textBox1.Text);
                MessageBox.Show("所查号码:" + num[0] + "\n归属省份:" + num[1] + "\n归属城市:" + num[2] + "\n城市区号:" + num[3] + "\n城市邮编:" +
                                num[4] + "\n卡 类 型:" + num[5], "查询结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,"错误提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            }
        }
作者:Bober Song
出处:http://bober.cnblogs.com/
衣冠勤售: http://www.YiGuanShou.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
posted @ 2012-01-04 13:38 衣冠勤售 阅读(15) 评论(0) 编辑 收藏
作者:Bober Song
出处:http://bober.cnblogs.com/
衣冠勤售:http://www.YiGuanShou.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。