function Xmlreader()
local aMail:={}
local hFile := FOpen( "c:\users\marc\downloads\archive.xml" )
Local oXmlDoc := TXmlDocument():New( hFile )
Local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual
while .T.
oTagActual = oXmlIter:Next()
If oTagActual != nil
if oTagActual:cName = "Email"
aadd(aMail,oTagActual:cData)
endif
if oTagActual:cName = "NewsletterID"
aadd(aMail,oTagActual:cData)
endif
if oTagActual:cName = "Subject"
aadd(aMail,oTagActual:cData)
endif
// MsgInfo( oTagActual:cName, oTagActual:cData )
// HEval( oTagActual:aAttributes, { | cKey, cValue | MsgInfo( cKey, cValue ) } )
Else
Exit
Endif
End
xbrowse(aMail)
FClose( hFile )
return nil
function druk_rappel(nRappel)
Local nDruk:=0, nDrukafstand:= 0.5, nDrukstart:= 8.5, nType:=0
nType = nRappel
aFacturen ={}
Public oPrn
Public oF12,oF12B,oF12I,oF12U,oFlarge
cRapport = "c:\programmas\rappels\rappels\rappel_"+alltrim(klant->klant_nr)+".pdf"
ferase(cRapport)
PRINT oPrn FILE cRapport PREVIEW
DEFINE FONT oF12 NAME "CAMBRIA" SIZE 0, -10 OF oPrn
DEFINE FONT oF12B NAME "CAMBRIA" BOLD SIZE 0, -10 OF oPrn
DEFINE FONT oF12I NAME "CAMBRIA" ITALIC SIZE 0, -10 OF oPrn
DEFINE FONT oF10 NAME "CAMBRIA" SIZE 0, -10 OF oPrn
DEFINE FONT oF12U NAME "CAMBRIA" UNDERLINE BOLD SIZE 0, -10 OF oPrn
DEFINE FONT oFLarge NAME "CAMBRIA" BOLD SIZE 0, -22 OF oPrn
oPrn:startpage()
hoofding(oPrn,"RAP") // afdruk hoofding
nDruk = nDrukstart
do case
case nType = 1 // eerste rappel per mail
oPrn:cmsay (nDruk,2,"Betreft : Openstaande facturen",oF12b)
oPrn:cmsay (nDruk+1.0,2,"Geachte klant,",oF12)
oPrn:cmsay (nDruk+2.0,2,"Met dit ",oF12)
oPrn:cmsay (nDruk+2.5,2,"overschr",oF12)
oPrn:cmsay (nDruk+3.0,2,"Gelieve ",oF12)
oPrn:cmsay (nDruk+4,2,"Hieronder kan U het overzicht vinden van de openstaande facturen : ",oF12)
endcase
nDruk = nDruk + 4 + 1
// Facturen blok
oPrn:cmsay (nDruk,2," Document Datum Verval Datum Bedrag Dagen",oF12u)
nDruk += nDrukafstand
nSubsaldo := 0
facturen->(dbgotop())
do while !facturen->(eof())
if !facturen->select
facturen->(dbskip())
loop
endif
cFactuur = "d:\facturen\" + alltrim(str(facturen->factuur,6))+".pdf"
if file(cFactuur)
aadd(afacturen,{cFactuur,cFactuur})
else
msginfo("Factuur "+cFactuur+" niet gevonden")
endif
oPrn:cmsay (nDruk,2.3,str(facturen->factuur,6,0),oF12)
oPrn:cmsay (nDruk,4.3,dtoc(facturen->datum),oF12)
oPrn:cmsay (nDruk,7.3,dtoc(facturen->vervaldat),oF12)
oPrn:cmsay (nDruk,11.5,str(facturen->totaal,9,2),oF12,,,,1)
oPrn:cmsay (nDruk,13.5,str( (date()-facturen->vervaldat),9,0),oF12,,,,1)
nDruk += nDrukafstand
facturen->(dbskip())
enddo
nDruk += nDrukafstand
*/
do case
case nType >= 1
oPrn:cmsay (nDruk,2,"Gelieve te storten op rekening : ",oF12)
nDruk += nDrukafstand+0.5
oPrn:cmsay (nDruk,2,"Hopend op een spoedige regeling, verblijven wij,",oF12)
nDruk += 2
oPrn:cmsay (nDruk+0,2,"Met de meeste hoogachting,",oF12)
oPrn:cmsay (nDruk+0.5,2,"De Boekhouding",oF12)
endcase
nDruk += 2
oPrn:cmsay (nDruk,2,"Vragen over deze a" ,oF10)
oPrn:endpage()
//oPrn:Preview()
ENDPRINT
oF12:end();oF12B:end();oF12I:end();oF12U:end();oFlarge:end();oPrn:end()
return
Marc Venken wrote:You open a XML file...
Maybe this function can help you...
- Code: Select all Expand view
function Xmlreader()
local aMail:={}
local hFile := FOpen( "c:\users\marc\downloads\archive.xml" )
Local oXmlDoc := TXmlDocument():New( hFile )
Local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual
while .T.
oTagActual = oXmlIter:Next()
If oTagActual != nil
if oTagActual:cName = "Email"
aadd(aMail,oTagActual:cData)
endif
if oTagActual:cName = "NewsletterID"
aadd(aMail,oTagActual:cData)
endif
if oTagActual:cName = "Subject"
aadd(aMail,oTagActual:cData)
endif
// MsgInfo( oTagActual:cName, oTagActual:cData )
// HEval( oTagActual:aAttributes, { | cKey, cValue | MsgInfo( cKey, cValue ) } )
Else
Exit
Endif
End
xbrowse(aMail)
FClose( hFile )
return nil
FUNCTION MAIN()
ESTRAI( "your xml here" )
RETURN NIL
STATIC FUNCTION ESTRAI( cXml )
LOCAL cTxt := MEMOREAD( cXml )
LOCAL nSta, nLen, cPdf
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 130 ) + CHR( 4 ) + CHR( 0 ), "" )
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 81 ), "" )
nSta = AT( "<NomeAttachment>", cTxt ) + 16
nLen = AT( "</NomeAttachment>", cTxt, nSta ) - nSta
cPdf = SUBSTR( cTxt, nSta, nLen )
nSta = AT( "<Attachment>", cTxt ) + 12
nLen = AT( "</Attachment>", cTxt, nSta ) - nSta
cTxt = SUBSTR( cTxt, nSta, nLen )
cTxt = HB_BASE64DECODE( cTxt )
MEMOWRIT( cPdf, cTxt, .F. )
RETURN NIL
Enrico Maria Giordano wrote:Try this:
- Code: Select all Expand view
FUNCTION MAIN()
ESTRAI( "your xml here" )
RETURN NIL
STATIC FUNCTION ESTRAI( cXml )
LOCAL cTxt := MEMOREAD( cXml )
LOCAL nSta, nLen, cPdf
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 130 ) + CHR( 4 ) + CHR( 0 ), "" )
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 81 ), "" )
nSta = AT( "<NomeAttachment>", cTxt ) + 16
nLen = AT( "</NomeAttachment>", cTxt, nSta ) - nSta
cPdf = SUBSTR( cTxt, nSta, nLen )
nSta = AT( "<Attachment>", cTxt ) + 12
nLen = AT( "</Attachment>", cTxt, nSta ) - nSta
cTxt = SUBSTR( cTxt, nSta, nLen )
cTxt = HB_BASE64DECODE( cTxt )
MEMOWRIT( cPdf, cTxt, .F. )
RETURN NIL
EMG
Harbour 3.2.0dev (r1712141320)
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling 'test.prg'...
test.prg(293) Error E0021 Incorrect number of arguments in AT
Passed: 3, expected: 2
test.prg(296) Error E0021 Incorrect number of arguments in AT
Passed: 3, expected: 2
2 errors
Enrico Maria Giordano wrote:Try this:
- Code: Select all Expand view
FUNCTION MAIN()
ESTRAI( "your xml here" )
RETURN NIL
STATIC FUNCTION ESTRAI( cXml )
LOCAL cTxt := MEMOREAD( cXml )
LOCAL nSta, nLen, cPdf
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 130 ) + CHR( 4 ) + CHR( 0 ), "" )
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 81 ), "" )
nSta = AT( "<NomeAttachment>", cTxt ) + 16
nLen = AT( "</NomeAttachment>", cTxt, nSta ) - nSta
cPdf = SUBSTR( cTxt, nSta, nLen )
nSta = AT( "<Attachment>", cTxt ) + 12
nLen = AT( "</Attachment>", cTxt, nSta ) - nSta
cTxt = SUBSTR( cTxt, nSta, nLen )
cTxt = HB_BASE64DECODE( cTxt )
MEMOWRIT( cPdf, cTxt, .F. )
RETURN NIL
EMG
cTxt = SUBSTR( cTxt, nSta, nLen )
cTxt = HB_BASE64DECODE( cTxt )
MEMOWRIT( cPdf, cTxt, .F. )
Enrico Maria Giordano wrote:Because the PDF is encoded Base64 inside the file XML:
<Attachment>...base64code...</Attachment>
EMG
Enrico Maria Giordano wrote:Because the PDF is encoded Base64 inside the file XML:
<Attachment>...base64code...</Attachment>
EMG
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: George, Google [Bot], nageswaragunupudi and 25 guests