Hi Salvadori,

The xmlns being added to each element is done by Microsoft's MSXML module and is done as it did not detect xmlns as a namespace but just an attribute and that is right as you've started your XML document without a namespace and 'just' added xmlns as attribute.

The solution is very simple. Switch to the Namespace aware/supporting messages. So CreateDocumentElementNS instead of CreateDocumentElement and AddElementNS instead of AddElement

Changed code (changes in bold):
Code:
Define C_NS for "http://www.portalfiscal.inf.br/cte"

    Handle hoXML hoRoot hoconsNSU hoRoot1 hoRoot2
    Boolean bNotOk

    Get Create U_cXMLDOMDocument to hoXML

    Set psDocumentName of hoXML to "c:\tmp\consulta_dfe.XML"
    
    Get CreateDocumentElementNS of hoXML C_NS "distDFeInt" to hoRoot

    Send AddAttributeNS of hoRoot C_NS "versao" "1.00"

    Send AddElementNS of hoRoot C_NS "tpAmb"   "1"

    Send AddElementNS of hoRoot C_NS "cUFAutor" "35"
    Send AddElementNS of hoRoot C_NS "CNPJ" "99999999999999"

    Get AddElementNS of hoRoot C_NS "consNSU" "" to hoconsNSU

    Send AddElementNS of hoconsNSU C_NS "NSU" "123456789012345"

    Get CreateChildProcessingInstruction of hoRoot "xml" 'version="1.0" encoding="UTF-8"' to hoRoot1

    Get InsertBeforeNode of hoXML hoRoot1 hoRoot to hoRoot2

    Get SaveXMLDocument of hoXML to bNotOk