Thursday

xdocument elements getting by SafeElement function


public string SafeElem(XDocument x, string tag, string _default_)
{
string r = _default_;
IEnumerable<XElement> a = x.Elements(tag);
if (a!=null && a.Count() >0)
{
string g= a.First().Value;
if (!string.IsNullOrEmpty(g))
{
r = g;
}
}
return r;
}


No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...