Implementation Code of asp.net mobile phone number location query

Source: Internet
Author: User

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:


 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.