public string DownloadWeatherXML() { try { string xml = new WebClient().DownloadString(_url); string modifiedxml = xml.Replace("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \r\n", ""); return modifiedxml; } catch (Exception e) { LogErrors LogObj = new LogErrors(); LogObj.InsertErrors(e.Message, e.Source, e.StackTrace, e.TargetSite.ToString()); return null; } }
public string DownloadWeatherXML() { try { string xml = new WebClient().DownloadString(_url); string modifiedxml = xml.Replace("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \r\n", ""); return(modifiedxml); } catch (Exception e) { LogErrors LogObj = new LogErrors(); LogObj.InsertErrors(e.Message, e.Source, e.StackTrace, e.TargetSite.ToString()); return(null); } }
// This method calls a stored proc to insert the xml into a staging temp table public void InsertData(string XmlStrObj) { using (SqlConnection conn = new SqlConnection(_connstr)) { try { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "CheckAndInsertData"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@raw_xml", SqlDbType.Xml); cmd.Parameters["@raw_xml"].Value = XmlStrObj; cmd.Connection = conn; cmd.ExecuteNonQuery(); } catch (Exception e) { LogErrors LogObj = new LogErrors(); LogObj.InsertErrors(e.Message, e.Source, e.StackTrace, e.TargetSite.ToString()); } } }