开发者

making an XML call to WhoisAPI [closed]

开发者 https://www.devze.com 2022-12-27 02:19 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update t开发者_运维技巧he question so it focuses on one problem only b
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update t开发者_运维技巧he question so it focuses on one problem only by editing this post.

Closed 4 years ago.

Improve this question

i just got an account at:

http://www.whoisxmlapi.com/index.php#/whois-api-doc.php?rid=1

ive never parsed XML with c#, how would i get the information in the <email> tag ?


I know of three options:

  • Linq to XML (.NET Framework 3.5)
  • XmlDocument
  • XmlReader

XmlDocument example:

XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
string email = doc.SelectSingleNode("/WhoisRecord/registrant/email").InnerText;

XmlReader example:

using (XmlReader reader = new XmlTextReader(new StringReader(xml)))
{
    reader.Read(); 
    reader.ReadStartElement("WhoisRecord");  
    reader.ReadStartElement("registrant");  
    reader.ReadStartElement("email");  
    reader.ReadString().Dump();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消