kevin bredahl

kevin bredahl

  • NA
  • 18
  • 6.8k

XML problems

May 18 2014 3:46 AM
hi i am working on an application that handles products.
and i wil write ea product in an xml file.

i can write my stuf o the xml file but when i look it up it stand realy wierd. like this:
<?xml version="1.0" encoding="utf-8"?><PRODUKT><NAVN>teste</NAVN><NUMMER>1234</NUMMER><MÆRKE>jaja</MÆRKE><PRIS>123456</PRIS><SPEC>test spec</SPEC></PRODUKT>

i stands in one line and like a normal xml tree. 
my code for the xml writer is:

{
XmlTextWriter writer = new XmlTextWriter(proNavnTb.Text + ".xml",Encoding.UTF8);
writer.WriteStartDocument();

writer.WriteStartElement("PRODUKT");

writer.WriteStartElement("NAVN");
writer.WriteString(proNavnTb.Text);
writer.WriteEndElement(); //NAVN

writer.WriteStartElement("NUMMER");
writer.WriteString(proNrTb.Text);
writer.WriteEndElement(); //NUMMER

writer.WriteStartElement("MÆRKE");
writer.WriteString(proBrandTb.Text);
writer.WriteEndElement(); //MÆRKE

writer.WriteStartElement("PRIS");
writer.WriteString(proPrisTb.Text);
writer.WriteEndElement(); //PRIS

writer.WriteStartElement("SPEC");
writer.WriteString(proBeskrivTb.Text);
writer.WriteEndElement(); //SPEC

writer.WriteEndElement(); //PRODUKT
writer.WriteEndDocument();
writer.Close();
}

what is going wrong in my code. i cant figure it out
so please help

Answers (4)