Hi,
I have a method that inserts class data into a new xml document, however I would like to append the data after the last element of an existing xml document.
here is the code I have:
if anyone can offer any help or suggestions, that would be appreciated.
[CODE=c]public string Insert(string XMLFile)
{
string XMLDirectory = this.xmlDir + this.ProjectorS N + @"\";
string file = XMLDirectory + XMLFile;
System.Xml.XmlT extWriter writer;
if (!System.IO.Dir ectory.Exists(X MLDirectory))
{
System.IO.Direc tory.CreateDire ctory(XMLDirect ory);
}
writer = new System.Xml.XmlT extWriter(file, System.Text.Enc oding.UTF8);
writer.Formatti ng = System.Xml.Form atting.Indented ;
writer.WriteSta rtDocument();
writer.WriteSta rtElement("Prod uctTest");
writer.WriteEle mentString("Pro ductSN", this.ProjectorS N);
writer.WriteEle mentString("Pac kageID", this.LightEngin eSN);
writer.WriteEle mentString("Par t2", this.Lamp1);
writer.WriteEle mentString("Par t3", this.Lamp2);
writer.WriteEle mentString("Dat eTime", this.DateTime);
writer.WriteWhi tespace(" ");
// Write End of root element
writer.WriteEnd Element();
// Write End of document
writer.WriteEnd Document();
writer.Close();
return (XMLDirectory + XMLFile + " saved.");
}[/CODE]
I have a method that inserts class data into a new xml document, however I would like to append the data after the last element of an existing xml document.
here is the code I have:
if anyone can offer any help or suggestions, that would be appreciated.
[CODE=c]public string Insert(string XMLFile)
{
string XMLDirectory = this.xmlDir + this.ProjectorS N + @"\";
string file = XMLDirectory + XMLFile;
System.Xml.XmlT extWriter writer;
if (!System.IO.Dir ectory.Exists(X MLDirectory))
{
System.IO.Direc tory.CreateDire ctory(XMLDirect ory);
}
writer = new System.Xml.XmlT extWriter(file, System.Text.Enc oding.UTF8);
writer.Formatti ng = System.Xml.Form atting.Indented ;
writer.WriteSta rtDocument();
writer.WriteSta rtElement("Prod uctTest");
writer.WriteEle mentString("Pro ductSN", this.ProjectorS N);
writer.WriteEle mentString("Pac kageID", this.LightEngin eSN);
writer.WriteEle mentString("Par t2", this.Lamp1);
writer.WriteEle mentString("Par t3", this.Lamp2);
writer.WriteEle mentString("Dat eTime", this.DateTime);
writer.WriteWhi tespace(" ");
// Write End of root element
writer.WriteEnd Element();
// Write End of document
writer.WriteEnd Document();
writer.Close();
return (XMLDirectory + XMLFile + " saved.");
}[/CODE]