G
Guest
I'm a new at C# - so please forgive my ignorance. The following 2 snippets
of code seem to be fairly equivalent. Is there any advantage to using 1 over
the other? Example 2 seems to be much more efficient...
Example 1:
XmlTextReader xtr = new
XmlTextReader(HttpContext.Current.Server.MapPath("DogData.xml"));
XmlDataDocument xdd = new XmlDataDocument();
DataSet ds = xdd.DataSet;
ds.ReadXmlSchema(xtr);
xtr.Close ();
xtr = new XmlTextReader(HttpContext.Current.Server.MapPath("DogData.xml"));
xdd.Load(xtr);
xtr.Close();
return ds;
Example 2:
DataSet ds = new DataSet();
ds.ReadXmlSchema(HttpContext.Current.Server.MapPath("DogData.xml"));
ds.ReadXml(HttpContext.Current.Server.MapPath("DogData.xml"));
return ds;
Thanks!
haiQ
of code seem to be fairly equivalent. Is there any advantage to using 1 over
the other? Example 2 seems to be much more efficient...
Example 1:
XmlTextReader xtr = new
XmlTextReader(HttpContext.Current.Server.MapPath("DogData.xml"));
XmlDataDocument xdd = new XmlDataDocument();
DataSet ds = xdd.DataSet;
ds.ReadXmlSchema(xtr);
xtr.Close ();
xtr = new XmlTextReader(HttpContext.Current.Server.MapPath("DogData.xml"));
xdd.Load(xtr);
xtr.Close();
return ds;
Example 2:
DataSet ds = new DataSet();
ds.ReadXmlSchema(HttpContext.Current.Server.MapPath("DogData.xml"));
ds.ReadXml(HttpContext.Current.Server.MapPath("DogData.xml"));
return ds;
Thanks!
haiQ