Autor Beitrag
3marci
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 61
Erhaltene Danke: 5

Windows 7 / Kubuntu 11.04
C# / vb.net / php / progress (VS 2010 Express / SharpDevelop / NetBeans / proAlpha)
BeitragVerfasst: Sa 05.03.11 17:53 
Ich erstelle mit folgendem Quelltext eine XML Datei.

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
XmlTextWriter XMLobj = new XmlTextWriter(FilePath, UnicodeEncoding.UTF8);
            
XMLobj.WriteStartDocument();
  XMLobj.WriteStartElement("xml");
    XMLobj.WriteStartElement("Element1""Value1");
    XMLobj.WriteEndElement();
    XMLobj.WriteStartElement("Element2""Value2");
    XMLobj.WriteEndElement();
  XMLobj.WriteEndElement();
XMLobj.WriteEndDocument();
XMLobj.Close();


Ich habe das Problem dass die XML Datei zwar einwandfrei erstellt wird (und auch ganz normal ausgelesen werden kann), aber in der XML Datei steht alles in einer Zeile...
Gibt es eine Möglichkeit dass das gleich schön geordnet wird?
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 05.03.11 18:04 
Du schlägst dich freiwillig mit dem XmlWriter herum :gruebel: ?
Schon Settings.Indent versucht?

_________________
>λ=
3marci Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 61
Erhaltene Danke: 5

Windows 7 / Kubuntu 11.04
C# / vb.net / php / progress (VS 2010 Express / SharpDevelop / NetBeans / proAlpha)
BeitragVerfasst: Sa 05.03.11 18:31 
Danke, mit dem Zusatz

ausblenden C#-Quelltext
1:
XMLobj.Settings.Indent = true;					


funktioniert das nicht, bzw. das Programm stürzt ab wenn es schreiben soll.
Ich habe das ganze so gelöst, und es funktioniert.

ausblenden C#-Quelltext
1:
2:
XmlTextWriter XMLobj = new XmlTextWriter(FilePath, UnicodeEncoding.UTF8);
XMLobj.Formatting = Formatting.Indented;