码迷,mamicode.com
首页 > Web开发 > 详细

抓包解析xml文件为json

时间:2014-11-06 12:29:33      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   ar   os   for   sp   

bubuko.com,布布扣
protected void Button1_Click(object sender, EventArgs e)
        {
            string Phone = this.Txt_Con.Text;
            string url = "http://api.showji.com/Locating/www.show.ji.c.o.m.aspx?m=" + Phone;

            foreach (string item in GetHttpXml(url))
            {

                TextBox1.Text += item + "\n";
            }
        }

        public string[] GetHttpXml(string url)
        {
            XmlDocument xml = new XmlDocument();
            xml.Load(url);
           
            XmlNamespaceManager xmlNm = new XmlNamespaceManager(xml.NameTable);
            xmlNm.AddNamespace("content", "http://api.showji.com/Locating/");
            XmlNodeList nodes = xml.SelectNodes("//content:QueryResult|//content:Mobile|//content:Province|//content:City|//content:Corp|//content:Card|//content:AreaCode|//content:PostCode", xmlNm);
            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};
                }
            }
            return new string[] { "FALSE" };
        }
Code

 

抓包解析xml文件为json

标签:des   style   blog   http   color   ar   os   for   sp   

原文地址:http://www.cnblogs.com/ingstyle/p/4078163.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!