The example of this article is about C # using Youdao IP Address query interface method. Share to everyone for your reference. The implementation methods are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#region Read http://www.yodao.com interface IP address///<summary>///Read http://www.yodao.com interface IP address///</summary> public The static string getstringipaddress (String StrIP)//strip is an IP {string surl = "http://www.youdao.com/smartresult-xml/ Search.s?type=ip&q= "+strip+"; Youdao URL string stringipaddress = ""; using (XmlReader read = Xmlreader.create (sURL))//Get Youdao returned XML format file content {while read. Read ()) {switch (read. NodeType) {Case xmlnodetype.text://takes the text content of an XML format file if (string. Format (' {0} ', read. Value). ToString (). Trim ()!= StrIP)//youdao returns the XML format file content one is IP,//Another is IP address, if not IP then is IP address {stringipaddress=string. Format (' {0} ', read. Value). ToString (). Trim ();//Assign value} break; "Other}}" return stringipaddress; } |
The returned XML data format:
?
1 2 3 4 5 6 7 |
<?xml version= "1.0" encoding= "GBK"?> <smartresult> <product type= "IP" > <ip>60.223.233.226 </ip> <location> Shanxi Shuozhou netcom </location> </product> </smartresult> |
I hope this article will help you with the C # program.