C # How to Use youdao IP address to query interface instances

Source: Internet
Author: User

C # How to Use youdao IP address to query interface instances

This example describes how to use the IP address query interface in C. Share it with you for your reference. The specific implementation method is 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 the IP address of the http://www.yodao.com Interface

/// <Summary>

// Read the IP address of the http://www.yodao.com Interface

/// </Summary>

Public static string GetstringIpAddress (string strIP) // the strIP is an IP address.

{

String sURL = "http://www.youdao.com/smartresult-xml/search.s? Type = ip & q = "+ strIP + "";

// Youdao URL

String stringIpAddress = "";

Using (XmlReader read = XmlReader. Create (sURL ))

// Obtain the content of the xml format file returned by youdao

{

While (read. Read ())

{

Switch (read. NodeType)

{

Case XmlNodeType. Text: // retrieve the Text content of an xml file

If (string. Format ("{0}", read. Value). ToString (). Trim ()! = StrIP)

// The content of the xml format file returned by youdao is an IP address,

// The other is an IP address. If it is not an IP address, it is an IP address.

{

StringIpAddress = string. Format ("{0}", read. Value). ToString (). Trim (); // assign a Value

}

Break;

// Other

}

}

}

Return stringIpAddress;

}

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 C # programming.

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.