Open the mobile phone number query website in a browser, find the address he called in the preceding steps, and write the code as follows:
The Code is as follows:
Using System;
Using System. Windows. Forms;
Using System. Xml;
Namespace HnVote
{
Public partial class Mobile: Form
{
Public Mobile ()
{
InitializeComponent ();
}
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 button#click (object sender, EventArgs e)
{
Try
{
String [] num = GetMobileInfo (textBox1.Text );
MessageBox. show ("number:" + num [0] + "n Province:" + num [1] + "n city: "+ num [2] +" n city code: "+ num [3] +" n city code: "+
Num [4] + "n card type:" + num [5], "query result", MessageBoxButtons. OK, MessageBoxIcon. Information );
}
Catch (Exception ex)
{
MessageBox. Show (ex. Message, "error prompt", MessageBoxButtons. OK, MessageBoxIcon. Warning );
}
}
Private void textBox1_KeyDown (object sender, KeyEventArgs e)
{
If (e. KeyCode = Keys. Enter)
{
Button#click (sender, e );
}
}
}
}
Interface: