I am generating an XML file using C# and I need to place multiple values inside a single attribute, attribute values are not supposed to be in a string outside the attribute. My group leader has requested it to be more read-able by adding line breaks after each value. I am quite struggling with figuring out how to do this.
The results have to be placed within a single attribute, creating multiple attributes or attribute + string is not an option.
What I have tried so far:
\n\r gives an "Invalid XML NCName" error;


 gives an "Invalid XML NCName" error;
I have not managed to find a different class than XDocument in C# which allows me to nicely place multiple variables in a single attribute and that supports line breaks.
Code is simplified but this is the idea of the workflow.
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment(" XML File "),
);
new XElement("Source1",
new XAttribute("id", SourceID[i]),
new XAttribute("active", SourceAct[i])
new XAttribute("gainDB", SourceGain[i]);
new XElement("Audio",
new XAttribute("id", IDSorted[i]),
new XAttribute("file", PathList[i])
)
doc.Save(@"XMLFiles/" + Description + ".xml");
What it prints:
<Source1 id="src:BlueSphere" gainDB="3.4" active="True" />
<AudioStream id="signal:violine" file="Assets/Audio/myaudio.wav" />`
What I need:
<Source1 id="src:BlueSphere"
gainDB="3.4"
active="True"/>
<AudioStream id="signal:violine"
file="Assets/Audio/myaudio.wav" />`
As I mentioned before, the code is simplified and in real life I have a lot more values within the attribute so it gets clogged up quite quickly.