Discussion:
[xHarbour-developers] Problem with XML
Enrico Maria Giordano
2017-01-27 10:05:30 UTC
Permalink
This is a sample of a problem with XML. Specifically, it doesn't read
the data

<![CDATA[2016-12-01]]>

It's been reported that it worked fine on June 2016.



#include 'hbxml.ch'

#define CRLF chr(13)+chr(10)

REQUEST DBFCDX
//------------------------------------------------------c---------------------//
function XML2RK()
LOCAL oXmlDoc,oXmlNode, oXmlRecScan, oXmlFieldScan
LOCAL set_4_, cFilename, cString, OXMLNODE00, OXMLRECSCAN0, OXMLNODE0,
tnumer, tdata, tnetto

setmode(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 nil




<?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>



EMG

--
http://www.emagsoftware.it
http://www.emagsoftware.it/emgmusic
http://www.emagsoftware.it/spectrum
http://www.emagsoftware.it/tbosg

Loading...