I'm using a namespace when I create my xml, but xmlns is also appearing in the below-root tag, this is damaging to me, how can I make xmlns stay in the root tag (TLote_GNRE)? Here is the code:
Dim xDoc As New XDocument(New XDeclaration("1.0", "utf-8", Nothing))
Dim nS As XNamespace = "http://www.gnre.pe.gov.br"
Dim xGuias As XElement = New XElement("guias")
xDoc.Add(New XElement(nS + "TLote_GNRE", xGuias))
Dim sw As New StringWriter()
Dim xWrite As XmlWriter = XmlWriter.Create(sw)
xDoc.Save(xWrite)
xWrite.Close()
xDoc.Save("C:\xml.xml")
XML output:
<?xml version="1.0" encoding="UTF-8"?>
<TLote_GNRE xmlns="http://www.gnre.pe.gov.br">
<guias xmlns=""/>
</TLote_GNRE>