Boa Tarde. Estou tendo alguns problemas em pegar as informações que estão em um arquivo XML, por favor se tiverem algumas dicas de como fazer isso eu agradeço.
boa tarde Fredson... olha se isso te ajuda: estou definindo uma temp e importando do arquivo (aqui vc tem que declarar o caminho inteiro), logo após (dentro do repeat) ele pega cada linha e vai gravando na temp. Agora vc pode tratar elas direto da temp. exemplo 1: vc seta quais as entradas que quer gravar na temp. Código: def var linha as char. def temp-table tabela no-undo field campo1 as int format "zzzzzz9" field campo2 as int format "zzzzzz9" field campo3 as char format "x(50)". input from arquivo.csv. repeat: import unformatted linha. create tabela. assign tabela.campo1 = int(entry( 3, linha, ";")) tabela.campo2 = int(entry( 4, linha, ";")) tabela.campo3 = entry( 5, linha, ";"). end. input close. exemplo 2: utiliza o comando delimiter, onde nao precisa setar campo a campo, mais é necessário importar todos os registros vindo do arquivo Código: input from arquivo.txt. repeat: create tabela. import delimiter ";" tabela.campo1 tabela.campo2 tabela.campo3. end. input close.
Código para ler um XML Progress 9.1D Espero que ajude! Código: def var x-dados as char. def var hDoc as handle. def var hRoot as handle. def var hTable as handle. def var hField as handle. def var hText as handle. /* =========================================== I N I C I O D O P R O C E S S A M E N T O =========================================== */ /* TESTA SE O FICHEIRO EXISTE */ if search(i-ficheiro) = ? then do: message "Ficheiro XML Inexistente" view-as alert-box error. o-estado = 1. return. end. /* CARREGA OS HANDLES DO XML */ create x-document hDoc. create x-noderef hRoot. create x-noderef hTable. create x-noderef hField. create x-noderef hText. /* LÒ O FICHEIRO XML */ hDoc:load ("file", i-ficheiro, false). hDoc:get-document-element (hRoot). do i = 1 to hRoot:num-children: hRoot:get-child (hTable,i). /* -- */ do j = 1 to hTable:num-children: hTable:get-child (hField,j). if hField:num-children < 1 then next. hField:get-child (hText,1). /* -- */ if x-dados = "" then x-dados = htext:node-value. else x-dados = x-dados + "|" + htext:node-value. end. end. /* -- */ do i = 1 to num-entries(x-dados,"|"): o-AdesaoFacturaElectronica_PTG = entry(1,x-dados,"|"). o-AdesaoFacturaElectronica_ING = entry(2,x-dados,"|"). o-AdesaoFacturaElectronica_FRA = entry(3,x-dados,"|"). o-AdesaoFacturaElectronica_ESP = entry(4,x-dados,"|"). end. /* DELETE OBJECT */ delete object hDoc. delete object hRoot. delete object hTable. delete object hField. delete object hText.
Eai... Você pode utilizar o READ-XML. Código: DEFINE VARIABLE cSourceType AS CHARACTER NO-UNDO. DEFINE VARIABLE cReadMode AS CHARACTER NO-UNDO. DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL NO-UNDO. DEFINE VARIABLE cFile AS CHARACTER NO-UNDO. DEFINE VARIABLE cEncoding AS CHARACTER NO-UNDO. DEFINE VARIABLE cSchemaLocation AS CHARACTER NO-UNDO. DEFINE VARIABLE cFieldTypeMapping AS CHARACTER NO-UNDO. DEFINE VARIABLE cVerifySchemaMode AS CHARACTER NO-UNDO. DEFINE VARIABLE returnValue AS LOGICAL NO-UNDO. DEFINE TEMP-TABLE ttAuth FIELD login AS CHARACTER FIELD senha AS CHARACTER. ASSIGN cSourceType = "FILE" cFile = "autentication.xml" cReadMode = "EMPTY" cSchemaLocation = ? lOverrideDefaultMapping = ? cFieldTypeMapping = ? cVerifySchemaMode = ?. returnValue = TEMP-TABLE ttAuth:READ-XML(cSourceType ,cFile , cReadMode ,cSchemaLocation ,lOverrideDefaultMapping ,cFieldTypeMapping , cVerifySchemaMode). IF returnValue THEN FOR EACH ttAuth: DISPLAY ttAuth WITH 1 COL 1 DOWN. END.