I've been tasked with creating a control to display the current Homeland Security Threat Level on our site's home page. Of course, I don't want to change anything when our threat level changes, so I went in search of a Web Service that gives me this information. I couldn't find a SOAP service, but I did find this URL provided by the Department of Homleand Security, which gives an XML string containing the current threat level.
I created this following enumeration that represents the current condition, so that I can use this information from within our .NET framework.
public enum DHSAdvisoryLevel
{
SEVERE,
HIGH,
ELEVATED,
GUARDED,
LOW,
UNKNOWN
}
And this static method to parse the DHSA's XML and return my enum.
public static DHSAdvisoryLevel GetHomelandSecurityThreatLevel()
{
DHSAdvisoryLevel currentLevel = DHSAdvisoryLevel.UNKNOWN;
try
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load("http://www.dhs.gov/dhspublic/getAdvisoryCondition");
System.Xml.XmlNodeList el = doc.GetElementsByTagName("THREAT_ADVISORY");
string threatLevel = el[0].Attributes["CONDITION"].Value;
currentLevel = (DHSAdvisoryLevel) Enum.Parse(typeof(DHSAdvisoryLevel),
threatLevel, true);
}
catch
{
// Do something here, if needed
}
return currentLevel;
}
Now, what would be really cool is for someone to host a Web Service that returns this enum... Any takers?
-Brendan