1
I need to build an XML like 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 assemble an empty initial XML, but when I add a new client for example (like Client-1), my code duplicates the Clients tag. The same thing happens with systems. I’m doing it this way with systems (example of System-1):
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? Thank you!
Like
duplica a tag de clientes
? Post as is the XML and the code you are using to add a client...– Jéf Bueno
The example of the code is for systems tag that is happening the same thing with customers. Inside XML I have the <Meuxml> tag and inside it the <Clients> and <Systems> tags, after I run the code I added to the post the <Systems> tag appears twice, and I need it to appear only once, understood?
– André Morais Martins