Page 1 of 4

FROM XML TO DBF

Posted: Fri Jan 13, 2023 6:57 am
by tomtagaris
I have e file xls
How can I extract its contents and pass them to a DBF file
Thanks for help

Re: FROM XML TO DBF

Posted: Fri Jan 13, 2023 4:34 pm
by HGAutomator
Hi Tom,

I searched around for xml to dbf code, but so far could only find a dbf_to_xml routine.

I used the commercial CoolUtils XML converter, to generate the attached.

Re: FROM XML TO DBF

Posted: Fri Jan 13, 2023 5:04 pm
by HGAutomator
Also this, from WhiteRock software. It's a single dbf as opposed to several in the last sample.

It looks like there are some string conversion problems, perhaps related to Unicode.

Re: FROM XML TO DBF

Posted: Sat Jan 14, 2023 3:47 am
by Claudio Ricardo
Hi... Try open with LibreOffice Calc (Similar to MsOffice Excel but open source and free !)
fix column width, and save to " dBase .dbf " I always do it, never fail !

Re: FROM XML TO DBF

Posted: Sat Jan 14, 2023 11:21 am
by dragancesu
XML is an interesting format, basically an TXT file that you read as text
but you can see the structure in it, in this case the record is INVOICE

Code: Select all

    <invoice>
      <uid>767DE28C469B8930A2262FC9660FBC93E5E6CB08</uid>
      <mark>400000000090274</mark>
      <issuer>
        <vatNumber>300950992</vatNumber>
        <country>GR</country>
        <branch>0</branch>
      </issuer>
      <counterpart>
        <vatNumber>029690710</vatNumber>
        <country>GR</country>
        <branch>0</branch>
        <address>
          <postalCode>25001</postalCode>
          <city>ΚΑΛΑΒΡΥΤΑ</city>
        </address>
      </counterpart>
      <invoiceHeader>
        <series>0</series>
        <aa>7465</aa>
        <issueDate>2020-10-11</issueDate>
        <invoiceType>1.1</invoiceType>
        <vatPaymentSuspension>false</vatPaymentSuspension>
        <currency>EUR</currency>
        <movePurpose>1</movePurpose>
      </invoiceHeader>
      <paymentMethods>
        <paymentMethodDetails>
          <type>5</type>
          <amount>0</amount>
        </paymentMethodDetails>
      </paymentMethods>
      <invoiceDetails>
        <lineNumber>1</lineNumber>
        <netValue>96.6</netValue>
        <vatCategory>2</vatCategory>
        <vatAmount>12.56</vatAmount>
      </invoiceDetails>
      <invoiceSummary>
        <totalNetValue>96.6</totalNetValue>
        <totalVatAmount>12.56</totalVatAmount>
        <totalWithheldAmount>0</totalWithheldAmount>
        <totalFeesAmount>0</totalFeesAmount>
        <totalStampDutyAmount>0</totalStampDutyAmount>
        <totalOtherTaxesAmount>0</totalOtherTaxesAmount>
        <totalDeductionsAmount>0</totalDeductionsAmount>
        <totalGrossValue>109.16</totalGrossValue>
      </invoiceSummary>
    </invoice>
notepad++ displays xml nicely

the problem is that the tags are long and the dbf fields are limited to 10 characters
I think it is not difficult to write a program that will write this data into the appropriate structure

Re: FROM XML TO DBF

Posted: Sat Jan 14, 2023 2:50 pm
by IMATECH

Re: FROM XML TO DBF

Posted: Sat Jan 14, 2023 3:51 pm
by edk
See this tool:
XmlToPrg.7z
(3.09 KiB) Downloaded 199 times
You can generate a prg which can be helpful for parsing the xml and writing the read data to the DBF.
You can also put the read data in an array and then process its contents.
Your sample xml file contains 999 invoices, but I "don't like" the Greek city and street names written in it. The xml file is declared as UTF-8, but Greek letters appear strangely for me.
greek utf8.png
greek utf8.png (82.88 KiB) Viewed 6917 times

Re: FROM XML TO DBF

Posted: Sat Jan 14, 2023 8:28 pm
by AUGE_OHR
hi,
IMATECH wrote: Sat Jan 14, 2023 2:50 pm hb_mxml ! read and write XML files
is hbmxml avaiable for HMG :?:

i did found hbmxml.LIB but that is for BCC or MSVC

Re: FROM XML TO DBF

Posted: Sat Jan 14, 2023 11:00 pm
by IMATECH
for sure:

sources
c:\hmg\harbour\contrib\hbmxml

lib
c:\hmg\harbour\lib\libhbmxml

Re: FROM XML TO DBF

Posted: Sat Jan 14, 2023 11:52 pm
by AUGE_OHR
hi
IMATECH wrote: Sat Jan 14, 2023 11:00 pm lib
c:\hmg\harbour\lib\libhbmxml
found it, thx