FROM XML TO DBF

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: FROM XML TO DBF

Post by tomtagaris »

Τhank you all for your help
Thanasis
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: FROM XML TO DBF

Post by serge_girard »

I really prefer files in DBF or simple flatfiles.... XML and JSON are not for humans?

Serge
There's nothing you can do that can't be done...
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: FROM XML TO DBF

Post by tomtagaris »

I finally followed the solution of EDK who I thank from the bottom of my heart for the help he has offered me. And I would like ask for a problem I am encountering in the transfer to dbf of the date from an hml file because it is in yyyy-mm-dd format I convert it with SUBSTR() in ctod( dd/mm/yyyy) format but some dates are not transferred βut is empty (//) like this
can someone help me
thanks
User avatar
dragancesu
Posts: 921
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: FROM XML TO DBF

Post by dragancesu »

edk
Posts: 914
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: FROM XML TO DBF

Post by edk »

tomtagaris wrote: Mon Jan 23, 2023 8:55 am And I would like ask for a problem I am encountering in the transfer to dbf of the date from an hml file because it is in yyyy-mm-dd format I convert it with SUBSTR() in ctod( dd/mm/yyyy) format but some dates are not transferred βut is empty (//) like this
can someone help me
thanks
The easiest way is to use the function hb_CtoD(<cDate> [, <cDateFormat>]) -> dDate, for example:

Code: Select all

REPLACE issueDate WITH hb_CtoD( cXmlIssueDate, "YYYY-MM-DD" )
@dragancesu
The function will convert a string to a date variable. So it doesn't matter what date display format you have set.
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: FROM XML TO DBF

Post by tomtagaris »

Thanks very much
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: FROM XML TO DBF

Post by tomtagaris »

one more question
how to export if there are many lines
<invoiceDetails>
<lineNumber>1</lineNumber>
<quantity>15</quantity>
<measurementUnit>1</measurementUnit>
<netValue>48.45</netValue>
<vatCategory>1</vatCategory>
<vatAmount>11.63</vatAmount>
</invoiceDetails>
<invoiceDetails>
<lineNumber>2</lineNumber>
<quantity>2</quantity>
<measurementUnit>1</measurementUnit>
<netValue>25.74</netValue>
<vatCategory>1</vatCategory>
<vatAmount>6.18</vatAmount>
</invoiceDetails>
<invoiceDetails>
<lineNumber>3</lineNumber>
<quantity>30</quantity>
<measurementUnit>1</measurementUnit>
<netValue>25.5</netValue>
<vatCategory>1</vatCategory>
<vatAmount>6.12</vatAmount>
</invoiceDetails>
<invoiceDetails>
<lineNumber>4</lineNumber>
<quantity>2</quantity>
<measurementUnit>1</measurementUnit>
<netValue>30</netValue>
<vatCategory>1</vatCategory>
<vatAmount>7.2</vatAmount>
</invoiceDetails>
<invoiceDetails>
<lineNumber>5</lineNumber>
<quantity>3</quantity>
<measurementUnit>1</measurementUnit>
<netValue>19.5</netValue>
<vatCategory>1</vatCategory>
<vatAmount>4.68</vatAmount>
</invoiceDetails>
<invoiceDetails>
<lineNumber>6</lineNumber>
<quantity>10</quantity>
<measurementUnit>1</measurementUnit>
<netValue>22</netValue>
<vatCategory>1</vatCategory>
<vatAmount>5.28</vatAmount>
edk
Posts: 914
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: FROM XML TO DBF

Post by edk »

Just:

Code: Select all

	CASE cKey == "uid" .AND. cPath == "RequestedDoc/invoicesDoc/invoice"
		SELECT invoice
		APPEND BLANK
		REPLACE invoice->iud WITH xValue

       ...

	CASE cKey == "lineNumber" .AND. cPath == "RequestedDoc/invoicesDoc/invoice/invoiceDetails"
		SELECT invoiceDetails
		APPEND BLANK
		REPLACE invoiceDetails->uid WITH invoice->iud
		REPLACE invoiceDetails->LineNumber WITH xValue
Last edited by edk on Mon Jan 30, 2023 12:30 pm, edited 1 time in total.
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: FROM XML TO DBF

Post by tomtagaris »

YES BUT WRITE ONLY ONE LINE BUT THE REST
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: FROM XML TO DBF

Post by tomtagaris »

ΟΚ I WILL TRY IT
ΤΗΑΝΚΣ
Post Reply