C # use Youdao IP Address Query interface Method Example

Source: Internet
Author: User
Tags trim

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.

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.