Asp.Net_抓包解析xml文件为json

时间:2023-03-08 17:53:29
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 == )
{
if ("True".Equals(nodes[].InnerText))
{ return new string[] { "手机号:"+nodes[].InnerText, "运行商:"+nodes[].InnerText, "归属省:"+nodes[].InnerText, "归属市:"+nodes[].InnerText,"城市区号:"+nodes[].InnerText,"城市邮编"+nodes[].InnerText};
}
}
return new string[] { "FALSE" };
}

Code