by kajot » Tue Jan 24, 2017 8:52 pm
my sample
t1.prg
//#include 'fivewin.ch'
#include 'hbxml.ch'
#define CRLF chr(13)+chr(10)
REQUEST DBFCDX
//------------------------------------------------------c---------------------//
function XML2RK()
local oDlg
local lSave := .f.
local oFont
local dd,mm,rr
LOCAL oXmlDoc,oXmlNode, oXmlRecScan, oXmlFieldScan
setpos(25,80)
cls
set_4_:=set(4,'yyyy-mm-dd')
begin sequence
cFileName := 'demo.xml'
If !file(cFileName)
break
Endif
cString:=Memoread( cFileName )
// cString:=strtran(cString,'<![CDATA[','')
// cString:=strtran(cString,']]>','')
oXmlDoc := TXmlDocument():new(,5) // ,HBXML_STYLE_NOESCAPE ) // HBXML_TYPE_CDATA HBXML_STYLE_NOESCAPE
if !( oXmlDoc:nError==HBXML_ERROR_NONE )
wait "xml file parsing error " + str(oXmlDoc:nError)
break
endif
oXMlDoc:read( cString )
oXmlNode00 := oXmlDoc:findFirst( "ROOT" )
oXmlRecScan0 := TXmlIteratorScan():new( oXmlNode00 )
oXmlNode0 := oXmlRecScan0:find( "REJESTRY_SPRZEDAZY_VAT" )
DO WHILE oXmlNode0 <> NIL
// oXmlFieldScan0 := TXmlIteratorScan():new( oXmlNode0 )
oXmlRecScan := TXmlIteratorScan():new( oXmlNode0 )
oXmlNode := oXmlRecScan:find( "REJESTR_SPRZEDAZY_VAT" )
DO WHILE oXmlNode <> NIL
tNUMER:=''
tDATA:=''
tNETTO:=''
oXmlFieldScan := TXmlIteratorScan():new( oXmlNode )
oXmlNode := oXmlFieldScan:find( "DATA" )
if oXmlNode#NIL
if oXmlNode:cData#NIL
tData:=oXmlNode:cData
endif
endif
oXmlNode := oXmlFieldScan:find( "NUMER" )
if oXmlNode#NIL
if oXmlNode:cData#NIL
tNUMER:=oXmlNode:cData
endif
endif
oXmlNode := oXmlFieldScan:find( "NETTO" )
if oXmlNode#NIL
if oXmlNode:cData#NIL
tNETTO:=oXmlNode:cData
endif
endif
alert('Data:'+tDATA+' '+'Numer:'+tNUMER+' '+'Netto:'+tNETTO)
oXmlNode := oXmlRecScan:next("REJESTR_SPRZEDAZY_VAT")
ENDDO
oXmlNode0 := oXmlRecScan0:next("REJESTRY_SPRZEDAZY_VAT")
ENDDO
end sequence
dbcloseall()
set(4,set_4_)
return
//------------------------------------------------------------------------------------//
demo.xml
-------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns="http://www.comarch.pl/cdn/optima/offline">
<REJESTRY_SPRZEDAZY_VAT>
<WERSJA>2.00</WERSJA>
<BAZA_ZRD_ID>SPRZE</BAZA_ZRD_ID>
<BAZA_DOC_ID>KSIEG</BAZA_DOC_ID>
<REJESTR_SPRZEDAZY_VAT>
<DATA>
<![CDATA[2016-12-01]]>
</DATA>
<NUMER>
<![CDATA[FA/1/12/2016/EXP]]>
</NUMER>
<NETTO>1400</NETTO>
</REJESTR_SPRZEDAZY_VAT>
</REJESTRY_SPRZEDAZY_VAT>
</ROOT>
t1.exe.xbp
-------------------------------------------------------------
CINI =
C_OUTPUTFOLDER =
DEFFILE =
INCLUDEFOLDERS =
LAUTORUN =
LDEBUG = .F.
LGUI = .F.
LIBFOLDERS =
LMT = .F.
LNOAUTOFWH = .F.
LPRG_CLASSICDEBUG = .F.
LPRG_DEBUG = .F.
LUSEDLL = .F.
MAPFILE =
MYC_FLAGS =
MYDEFINES =
MYLINK_FLAGS =
MYPRG_FLAGS =
MYRC_FLAGS =
MYSLY_FLAGS =
OUTPUTFOLDER =
PRG_OUTPUTFOLDER =
RC_OUTPUTFOLDER =
RUNARGUMENTS =
SLY_OUTPUTFOLDER =
STARTIN =
TARGETFOLDER =
[t1.prg]
MYC_FLAGS =
MYDEFINES =
MYPRG_FLAGS =
best regards
kajot