获取手机归属地

#region - 手机归属地 -
        private static string GetMobileInfo(string number)
        {
            string str = "";
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
          xmlDocument.Load(" http://vip.showji.com/locating/?m==" + number);
              //  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 != null)
                    if (nodes.Count == 8)
                    {
                        if ("True".Equals(nodes[1].InnerText))
                        {
                            str = nodes[0].InnerText + "," + nodes[2].InnerText + "," + nodes[3].InnerText + "," + nodes[4].InnerText + "," + nodes[5].InnerText + "," + nodes[6].InnerText + nodes[7].InnerText;
                        }
                    }
                return str;
            }
            catch (Exception)
            {
                return str;
            }
        }
        #endregion
 
 string str = GetMobileInfo(num);
                string[] array = str.Split(',');
                foreach (string m in array)
                {
                    Console.WriteLine(m.ToString());
                }

  

posted on 2012-05-02 13:43  lei0515  阅读(188)  评论(0)    收藏  举报

导航