Tha have a fairly lage XML file ~350k lines when formatted. The file is used by a purchased application. I have a requirement to refresh the demand records in the file. All the other data in the file should remain the same.
The kludgy process I am currently have implemented is using a streamReader to read each line of the current xml file and a textwriter to write the new file. The process reads, sees if the line it just read is the beginning tag <demandList> I am looking for, if it is not is just writes the line back to the new file, if it is the <demandList> tab, it goes into a method that reads some demand from a database, and writes out the new demand (using extra kludgy logic like this).
Loop for each demand record
Outfile.WriteLine("<demand type=""""Order"""">")
Outfile.WriteLine("<demandCode>" & custNum & "</demandCode>")
Outfile.WriteLine("<customerName></customerName>")
Outfile.WriteLine("<customerNumber>" & custNum & "</customerNumber>")
Outfile.WriteLine("<shipTo></shipTo>") ...etc
Once it is done writing all the demand it goes back to the file reads each line until if finds the end tag </demandList> once the end tag is found it goes back to reading and writing so that the final result is that only the <demandList> section of the xml file has been changed.
There has to be a better way, any ideas and examples would be welcome. This is my first .Net program so be gentle
Thanks in advance
The kludgy process I am currently have implemented is using a streamReader to read each line of the current xml file and a textwriter to write the new file. The process reads, sees if the line it just read is the beginning tag <demandList> I am looking for, if it is not is just writes the line back to the new file, if it is the <demandList> tab, it goes into a method that reads some demand from a database, and writes out the new demand (using extra kludgy logic like this).
Loop for each demand record
Outfile.WriteLine("<demand type=""""Order"""">")
Outfile.WriteLine("<demandCode>" & custNum & "</demandCode>")
Outfile.WriteLine("<customerName></customerName>")
Outfile.WriteLine("<customerNumber>" & custNum & "</customerNumber>")
Outfile.WriteLine("<shipTo></shipTo>") ...etc
Once it is done writing all the demand it goes back to the file reads each line until if finds the end tag </demandList> once the end tag is found it goes back to reading and writing so that the final result is that only the <demandList> section of the xml file has been changed.
There has to be a better way, any ideas and examples would be welcome. This is my first .Net program so be gentle
Thanks in advance