Write ti XML with C#



I am trying to collect and write some temporary data within xml file
before I put them into DB.
I am writing into xml file like follows:
private void WriteXML()
{
//Use the xmlTextWriter to open a new xml file
XmlTextWriter writer = new
XmlTextWriter(@"C:\\Data\\tblPomocnaTablica.xml",
System.Text.Encoding.UTF8);

//Write the root element
writer.WriteStartElement("tblTableX");

// Write the elements
writer.WriteElementString("ClientID", "2");
writer.WriteElementString("EmployeeID", "4");
writer.WriteElementString("ShopID", "100");
writer.WriteElementString("ProductID", "100");
writer.WriteElementString("Qty", "1");
// end the root element
writer.WriteEndElement();
// Flush
writer.Flush();
//Write the XML to file and close the writer
writer.Close();
}
It is works and I get something like this:
ClientID | EmployeeID | ProdavonicaID | ProductID | Qty |
2 | 4 | 100 | 100 |1 |
Two Questions
1) How I can write a new rows without rewriting existing rows,
for e.g.?
2 | 4 | 124 | 25 |1 |
etc.

Result should be something like this:
ClientID | EmployeeID | ProdavonicaID | ProductID | Qty |
------------------------------------------------------------------------
2 | 4 | 100 | 100 |1 |
2 | 4 | 124 | 25 |1 |

2) How I can change one value in some row, for e.g.
row 2 ShopID = 250, is that possible?
Thanks in advance
Mike
.



Relevant Pages

  • Re: getting XPath in REXML to dive deeper
    ... Gavin Kistner wrote: ... I've learned a bit about XPath and how REXML can use it. ... a sample XML file whose root element is. ...
    (comp.lang.ruby)
  • Re: Write to XML with C#
    ... Andrew Faust ... I am writing into xml file like follows: ... XmlTextWriter writer = new ... //Write the root element ...
    (microsoft.public.dotnet.languages.csharp)
  • Problem with SQLXML when using annotations.
    ... I'm using SQLXML 3.0 in C# .NET. ... When I validate the xml file against the schema. ... I tried it with Tablename as the root element and the columns as the child ...
    (microsoft.public.sqlserver.xml)
  • The root element problem:
    ... However, in the output .xml file, I saw its root element is, ... is actually the name of generated DataSet class. ... Can we write out a .xml file with its root element the same as its schema, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: getting XPath in REXML to dive deeper
    ... I've learned a bit about XPath and how REXML can use it. ... a sample XML file whose root element is. ... shorthand for the 'child' axis. ...
    (comp.lang.ruby)