Results 1 to 4 of 4

Thread: Create XML (U_cXMLDOMDocument)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2014
    Posts
    206

    Default Create XML (U_cXMLDOMDocument)

    Hello

    i'm trying to write a code that needs to create a xml like this:

    Code:
    <distDFeInt versao="1.00" xmlns="http://www.portalfiscal.inf.br/cte">
        <tpAmb>1</tpAmb>
        <cUFAutor>35</cUFAutor>
        <CNPJ>99999999999999</CNPJ>
        <consNSU>
            <NSU>123456789012345</NSU>
        </consNSU>
    </distDFeInt>
    

    i just try this way:

    Code:
    Get Create U_cXMLDOMDocument to hoXML                               
    
    
    Set psDocumentName of hoXML to ((fMontaCaminhoXmlServico("E",0)) + "consulta_dfe.XML")
    
    
    Get CreateDocumentElement of hoXML "distDFeInt" to hoRoot
    
    
    Send AddAttribute of hoRoot "versao" "1.00"  
    Send AddAttribute of hoRoot "xmlns" "http://www.portalfiscal.inf.br/cte"                
    
    
    Send AddElement of hoRoot "tpAmb"   "1"
    
    
    Send AddElement of hoRoot "cUFAutor" "35"
    Send AddElement of hoRoot "CNPJ" "99999999999999"
    
    
    Get AddElement of hoRoot "consNSU" "" to hoconsNSU
    
    
    Send AddElement of hoconsNSU "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
    the output is:

    Code:
    <distDFeInt xmlns="http://www.portalfiscal.inf.br/cte" versao="1.00">
        <tpAmb xmlns="">1</tpAmb>
        <cUFAutor xmlns="">35</cUFAutor>
        <CNPJ xmlns="">99999999999999</CNPJ>
        <consNSU xmlns="">
            <NSU>123456789012345</NSU>
        </consNSU>
    </distDFeInt>
    


    i dont want all tags with the attribute xmlns, what should i do for only the first one get the tag xmlns?

    thank you
    Last edited by Salvadori; 6-Jun-2018 at 02:29 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •