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

FROM XML TO DBF

Post by tomtagaris »

I have e file xls
How can I extract its contents and pass them to a DBF file
Thanks for help
Attachments
Request.zip
(105.12 KiB) Downloaded 151 times
HGAutomator
Posts: 188
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: FROM XML TO DBF

Post 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.
Attachments
Converted_XML.zip
(608.58 KiB) Downloaded 157 times
HGAutomator
Posts: 188
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: FROM XML TO DBF

Post 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.
Attachments
WhiteRock_XML_to_DBF.zip
(79.49 KiB) Downloaded 162 times
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: FROM XML TO DBF

Post 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 !
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
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 »

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
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: FROM XML TO DBF

Post by IMATECH »

M., Ronaldo

By: IMATECH

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

Re: FROM XML TO DBF

Post by edk »

See this tool:
XmlToPrg.7z
(3.09 KiB) Downloaded 138 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 5114 times
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: FROM XML TO DBF

Post 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
have fun
Jimmy
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: FROM XML TO DBF

Post by IMATECH »

for sure:

sources
c:\hmg\harbour\contrib\hbmxml

lib
c:\hmg\harbour\lib\libhbmxml
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: FROM XML TO DBF

Post by AUGE_OHR »

hi
IMATECH wrote: Sat Jan 14, 2023 11:00 pm lib
c:\hmg\harbour\lib\libhbmxml
found it, thx
have fun
Jimmy
Post Reply