Control of XML NameSpaces in C #

-2

Hello

I'm building an XML file and it has the xmlns attribute on the parent element, but I do not want it to appear in the child as it's occurring below:

FollowthecodeinC#language:

eSocialevt1210Lote=newXDocument(newXDeclaration("1.0", "UTF-8", "No"),
     new XElement(eSocial + "eSocial",
     new XElement("envioLoteEventos",
    
asked by anonymous 05.04.2018 / 13:35

1 answer

0

By reading the documentation I found the following: the xmlns attribute means NameSpace , and there are also several examples in the case, try this:

XNamespace nameSpace = "http://www.esocial...";

XElement xmlTree = new XElement(nameSpace + "eSocial",
     new XElement(eSocial + "eSocial",
     new XElement("envioLoteEventos",
);

Console.WriteLine(xmlTree );

I did not test, but I believe it to be.

    
05.04.2018 / 14:57