Autor Beitrag
xToast
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: So 21.11.10 21:12 
Mein Code sieht so aus:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
            XmlElement layoutElement = doc.CreateElement("Layout");
            rootElement.AppendChild(layoutElement);

            List<string> lines = new List<string>();

            for (int y = 0; y < Height; y++)
            {
                string line = String.Empty;

                for (int x = 0; x < Width; x++)
                {
                    line += map[y, x].ToString() + " ";
                }

                lines.Add(line);
            }

            foreach (string line in lines)
            {
                layoutElement.InnerText += line;
            }


map ist ein 2 Dimensionales Array (int[,]).
Mein Problem hierbei ist folgender: Nach line sollte eigentlich ein Umbruch kommen, weil mein ganzer Code sonst nicht funktioniert. Aber ich bekomme es einfach nicht hin, weil Xml weder "\n" noch "\r" akzeptiert, und ich deshalb keinen Umbruch hardcoden kann. Gibt es dafür vielleicht einen extra Befehl, eine Methode oder etwas in der Art, damit ich das Problem lösen kann?
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: So 21.11.10 21:53 
Mit der altbackenen XmlDocument-API kenne ich mich nicht aus, aber von XElement wüsste ich nicht, dass da automatisch irgendwelche Zeilenumbrüche weggeworfen würden:
ausblenden C#-Quelltext
1:
2:
3:
> XElement.Parse(new XElement("root""Hello" + Environment.NewLine + "World").ToString())
<root>Hello
World</root>

_________________
>λ=