C#XML Namespace Control

Asked

Viewed 64 times

-2

Hello!

I’m building an XML file and it has the xmlns attribute in the parent element, but I don’t want it to appear in the child as is happening below:

inserir a descrição da imagem aqui

Follow the code in C language#:

eSocialevt1210Lote = new XDocument(
     new XDeclaration("1.0", "UTF-8", "No"),
     new XElement(eSocial + "eSocial",
     new XElement("envioLoteEventos",

1 answer

0

Reading a little the documentation I found the following: the attribute xmlns means Namespace, and there are also several examples, in your case, test this:

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

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

Console.WriteLine(xmlTree );

I didn’t test it, but I believe that’s it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.