Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP6 - Função XMLTOCURSOR
Message
De
22/06/2002 15:53:14
 
 
À
21/06/2002 12:23:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00671078
Message ID:
00671398
Vues:
26
Ola a todos
>
>.. alguma função equivalente ao XMLTOCURSOR no VFP6
>
A todos que participaram deste thread o meu muitiiissiiimo obrigado.. Mas, tive que "partir" para uma solução mais "caseira" e construi as funções (com a ajuda do meus amigos António Lopes e Sergey Beres$@&%ker (O nome dele é russo e muito difícil de escrever) :))

Estou dividindo com vocês o resultado (caso algum de vocês necessitem)

Este programa lê o arquivo OFC ou OFX, e transforma-o em algo mais próximo do xml e então leva-o para um cursor no VFP 6:
CLOSE DATA

*** remonta o cursor dos dados OFC
cwxml=filetostring("c:\temp\7C1024593671.ofc")
* pode ser tambem -->> cwxml=filetostring("c:\temp\extrato.ofx")

*** converte o arquivo OFC
cwdata=converofctoxml(cwxml)

*** cria o cursor
createcursorfromxml(cwdata, "cur_xml")

*** atualiza
atualizacursorfromxml(cwdata, "cur_xml")
RETURN

FUNCTION atualizacursorfromxml
LPARAMETER cwxml, cwnomecur
DIMENSION m.laofc[1]
DIMENSION m.lacampos[1]
SELE (cwnomecur)
ALINES(m.laofc,cwxml)
i1=0
m.clinicio1 = 0
FOR EACH m.lclinha IN m.laofc
    IF  "</STMTTRN>"$m.lclinha
        INSERT INTO (cwnomecur) FROM MEMVAR
    ELSE
        m.lninicio = AT('<',m.lclinha)  && Acha o Campo
        m.lnfim    = AT('>',m.lclinha)
        IF  m.lninicio>0 AND m.lnfim>0 AND SUBSTR(m.lclinha,m.lninicio+1,1)!='/'
            wcampo  = "m."+SUBSTR(m.lclinha,m.lninicio+1,m.lnfim-m.lninicio-1)
            &wcampo = STUFF(m.lclinha,1,AT('>',m.lclinha),"")
            &wcampo = STUFF(&wcampo,AT('</',&wcampo),LEN(&wcampo),"")
        ENDIF
    ENDIF
ENDFOR
RETURN

FUNCTION createcursorfromxml
LPARAMETER cwxml, cwnomecur
DIMENSION m.laofc[1]
DIMENSION m.lafields[1,4]
DIMENSION m.lacampos[1]
m.lacampos[1]=""
i1=0
ALINES(m.laofc,cwxml)
FOR EACH m.lclinha IN m.laofc
    m.lninicio = AT('<',m.lclinha)
    m.lnfim    = AT('>',m.lclinha)
    IF  m.lninicio>0 AND m.lnfim>0 AND SUBSTR(m.lclinha,m.lninicio+1,1)!='/'
        IF  ASCAN(m.lacampos, SUBSTR(m.lclinha,m.lninicio+1,m.lnfim-m.lninicio))=0
            i1=i1+1
            DIMENSION m.lacampos[I1]
            m.lacampos[i1]   = SUBSTR(m.lclinha,m.lninicio+1,m.lnfim-m.lninicio)
            DIMENSION m.lafields[i1,4]
            m.lafields[i1,1] = SUBSTR(m.lclinha,m.lninicio+1,m.lnfim-m.lninicio)
            m.lafields[i1,2] = "C"
            m.lafields[i1,3] = 20
            m.lafields[i1,4] = 0
        ENDIF
    ENDIF
ENDFOR
SELE 0
CREATE CURSOR (cwnomecur) FROM ARRAY m.lafields
RETURN

FUNCTION converofctoxml
LPARAMETER cwxml
DECLARE m.laofc(1)
ALINES(m.laofc,cwxml)
*m.lcxml = '<datastructure name="lcalias">'+ CHR(13)+CHR(10)
m.lcxml = ''
FOR EACH m.lclinha IN m.laofc
    m.lcxml = m.lcxml + m.lclinha
    m.lninicio = AT('<',m.lclinha)
    m.lnfim = AT('>',m.lclinha)
    IF  m.lninicio>0 AND m.lnfim>0 AND SUBSTR(m.lclinha,m.lninicio+1,1)!='/'
        m.lcclosetag = '</'+SUBSTR(m.lclinha,m.lninicio+1,m.lnfim-m.lninicio)
        IF !m.lcclosetag $ cwxml
            m.lcxml = m.lcxml + m.lcclosetag
        ENDIF
    ENDIF
    m.lcxml = m.lcxml + CHR(13)+CHR(10)
ENDFOR

RETURN m.lcxml

FUNCTION filetostring
LPARAMETER lcdatafile
lndfh=FOPEN(lcdatafile)
lcparameter=""
IF  lndfh > 0
    nsize =  FSEEK(lndfh, 0, 2)
    IF  nsize <= 0
    ELSE
        = FSEEK(lndfh, 0, 0)
        DO WHILE NOT FEOF(lndfh)
            lcparameter=lcparameter+FREAD(lndfh,nsize)
            *            WAIT WINDOW "teste"
        ENDDO
    ENDIF
    =FCLOSE(lndfh)
ELSE
    * Error opening data file
ENDIF
RETURN lcparameter
Claudio
"Now to him who is able to do immeasurably more than all we ask or imagine, according to his power that is at work within us, Ephesians 3:20
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform