I need set a namespace in a child and in its child too, but, when I attribute the same namespace, the sub child comes with no namespace.
I need something like that:
<?xml version="1.0" encoding="UTF-8"?>
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
<infNFe versao="2.00" Id="NFe35120810609770000190550010000011151000011155">
...
But my code is generating only this:
<?xml version="1.0" encoding="UTF-8"?>
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
<NFe>
<infNFe versao="2.00" Id="NFe35120810609770000190550010000011151000011155">
...
The code that generates this part of the XML is:
Document doc = new Document();
Namespace portal = Namespace.getNamespace( "http://www.portalfiscal.inf.br/nfe" );
Element tagNfeProc = new Element( "nfeProc", portal );
tagNfeProc.setAttribute( "versao", "2.00" );
Element tagNFe = new Element( "NFe", portal );
...
tagNfeProc.getChildren().add( tagNFe );
doc.setRootElement( tagNfeProc );