Anyone saw a worst written function than this? [closed]
- by fvoncina
string sUrl = "http://www.ipinfodb.com/ip_query.php?ip=" + ip + "&output=xml";
StringBuilder oBuilder = new StringBuilder();
StringWriter oStringWriter = new StringWriter(oBuilder);
XmlTextReader oXmlReader = new XmlTextReader(sUrl);
XmlTextWriter oXmlWriter = new XmlTextWriter(oStringWriter);
while (oXmlReader.Read())
{
oXmlWriter.WriteNode(oXmlReader, true);
}
oXmlReader.Close();
oXmlWriter.Close();
// richTextBox1.Text = oBuilder.ToString();
XmlDocument doc = new XmlDocument();
doc.LoadXml(oBuilder.ToString());
doc.Save(System.Web.HttpContext.Current.Server.MapPath(".") + "data.xml");
DataSet ds = new DataSet();
ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath(".") + "data.xml");
string strcountry = "India";
if (ds.Tables[0].Rows.Count > 0)
{
strcountry = ds.Tables[0].Rows[0]["CountryName"].ToString();
}