Leave XML on a single line [closed]

0

My application in C # receives the indented xml. I need to leave this xml all in a single line. How can I do this?

    
asked by anonymous 04.05.2016 / 20:53

2 answers

1

If you get xml for a file:

XDocument document = XDocument.Load("arquivo.xml");
document.Save("arquivo2.xml", SaveOptions.DisableFormatting);

Or if you have xml in a string:

XDocument document = XDocument.Parse(stringXML);
document.Save("arquivo.xml", SaveOptions.DisableFormatting);
    
24.01.2017 / 11:57
0

You can separate the rows into array and then concatenate

string xml = dadosdoxml.ToString();

var separar = xml.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);

string final = string.Join(" ", separar );
    
05.05.2016 / 16:59