一千萬個為什麽

搜索

對WhoisAPI進行XML調用

我剛收到一個帳戶:

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 tag ?

最佳答案

我知道三種選擇:

XmlDocument示例:

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

XmlReader示例:

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

轉載註明原文: 對WhoisAPI進行XML調用