I am reading in and processing a html file and adding records to my SQL database each time the GUID element is read in.
I create the data structure at the start of the loop with the NEW action. Every time I add a record I manually clear out each field of the data record structure I am building in preparation of reading in the next set of html records.
private void importServiceCallTypeOfWorkMaster(string filename)
{ string lastID = null; string nodename = null; XmlTextReader reader = new XmlTextReader(filename); ServiceCallTypeOfWorkMaster sctwm = new ServiceCallTypeOfWorkMaster();
while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: nodename = reader.Name; break; case XmlNodeType.Text: switch (nodename) { case "TypeOfWorkID": writeRecordtoSQL(sctwm);
case "TypeOfWorkCode": sctwm.TypeOfWorkCode = reader.Value; break; case "TypeOfWorkDescription": sctwm.TypeOfWorkDescription = reader.Value; break;
}
break;
case XmlNodeType.EndElement: nodename = null; break;
public class ServiceCallTypeOfWorkMaster { private string typeOfWorkID; private string typeOfWorkCode; private string typeOfWorkDescription;
public ServiceCallTypeOfWorkMaster()
{ typeOfWorkID = ""; typeOfWorkCode = ""; typeOfWorkDescription = ""; }
public string TypeOfWorkID { get
{ return typeOfWorkID; }
set { typeOfWorkID = value; } }
public string TypeOfWorkCode { get { return typeOfWorkCode; } set { typeOfWorkCode = value; }
public string TypeOfWorkDescription { get { return typeOfWorkDescription; } set { typeOfWorkDescription = value; } } }