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 questioni 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();
}
精彩评论