我刚收到一个帐户:
http://www.whoisxmlapi.com/index.php#/whois-api-doc.php?rid=1
我从未用c#解析XML,我如何获得<email>
标签中的信息?
答案 0 :(得分:1)
我知道三个选项:
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();
}