I need to mount an XML as in the following example:
<?xml version="1.0" encoding="utf-8"?>
<MeuXML>
<Clientes>
<Cliente-1>Dados Cliente-1</Cliente>
</Clientes>
<Sistemas>
<Sistema-1>
<Pasta>Pasta do Sistema-1</Pasta>
<Origem>Origem do Sistema-1</Fontes>
</Sistema-1>
</Sistemas>
</MeuXMl>
I can even build an empty initial XML, but when I add a new client for example (such as Client-1), my code duplicates the Customers tag. The same thing happens with systems. I'm doing this with systems (System-1 example):
XElement xml = XElement.Load("Config.xml")
XElement xmlSistemas = XElement.Load("Config.xml").Elements("Sistemas").FirstOrDefault();
XElement xSistema1 = new XElement("Sistema-1");
XElement xPasta = new XElement("Pasta");
xPasta.Value = "Pasta do Sistema-1";
XElement xOrigem = new XElement("Origem");
xOrigem.Value = "Origem do Sistema-1";
xSistema1.Add(xPasta, xOrigem);
xmlSistemas.Add(xSistema1);
xml.Add(xmlSistemas);
xml.Save("Config.xml");
How can I fix this? Thanks!