Page 1 of 3

dbf to Xml

Posted: Fri Jan 23, 2009 5:01 pm
by Silvio
is there a function to create a xml from a dbf ?

Re: dbf to Xml

Posted: Sat Jan 24, 2009 4:08 am
by Antonio Linares
Silvio,

If you need to do it in a non programmatically way, then you can use i.e. OpenOffice calc to open the DBF and save it as XML:
Image

If you want to do it programmatically, then it is easy to do it as the XML format is very easy. Here you have an example for a RSS XML:

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Sources</title>
<link>http://www.fivetechsoft.com/news</link>
<description>Dynamic news reader</description>
<item>
<title>News</title>
<link>News</link>
<description>News sources</description>
<pubDate>23 Jan 2009 10:04 am</pubDate>
</item>
<item>
<title>Tech</title>
<link>Tech</link>
<description>Tech sources</description>
<pubDate>23 Jan 2009 10:04 am</pubDate>
</item>
</channel>
</rss> 
as you can see, you can easily generate a XML from a DBF, with the structure that better fits to your needs. Here I am openning the previous XML file using Internet Explorer:
Image

Re: dbf to Xml

Posted: Sat Jan 24, 2009 8:32 am
by Enrico Maria Giordano
Also try the following sample:

Code: Select all

#define adOpenForwardOnly 0
#define adOpenKeyset      1
#define adOpenDynamic     2
#define adOpenStatic      3

#define adLockReadOnly        1
#define adLockPessimistic     2
#define adLockOptimistic      3
#define adLockBatchOptimistic 4

#define adPersistXML 1


FUNCTION MAIN()

    LOCAL oRs := CREATEOBJECT( "ADODB.Recordset" )

    FERASE( "TEST.XML" )

    oRs:Open( "SELECT * FROM Test", "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=e:\xharbour; Extended Properties=DBASE III", adOpenForwardOnly, adLockReadOnly )

    oRs:Save( "TEST.XML", adPersistXML )

    oRs:Close()

    RETURN NIL
EMG

Re: dbf to Xml

Posted: Sat Jan 24, 2009 10:45 am
by Silvio
thanks to all
and How I can make with a prg ( xharbour and fwh) to converte a XML to a DBF ?

Re: dbf to Xml

Posted: Sat Jan 24, 2009 11:29 am
by Otto
Hello Silvio,

Timm (http://www.reportdesigner.info/) has a XML-reader class for download on his homepage.

Regards,
Otto

Re: dbf to Xml

Posted: Sat Jan 24, 2009 2:57 pm
by Enrico Maria Giordano

Code: Select all

FUNCTION MAIN()

    LOCAL oStream, oRs

    oStream = CREATEOBJECT( "ADODB.Stream" )

    oStream:Open()

    oStream:WriteText( MEMOREAD( "TEST.XML" ) )

    oStream:Position = 0

    oRs = CREATEOBJECT( "ADODB.Recordset" )

    oRs:Open( oStream )

    oStream:Close()

    WHILE !oRs:EOF
        ? oRs:Fields( "Last" ):Value, oRs:Fields( "First" ):Value
        oRs:MoveNext()
    ENDDO

    oRs:Close()

    INKEY( 0 )

    RETURN NIL
EMG

Re: dbf to Xml

Posted: Sat Jan 24, 2009 4:02 pm
by Silvio
I must Know the fields of archive ?
I have these on the top of this archive
I have a sample XML
look it pls

Code: Select all

  <?xml version="1.0" standalone="yes" ?> 
- <DATAPACKET Version="2.0">
- <METADATA>
- <FIELDS>
  <FIELD attrname="ICLSSESMATID" fieldtype="i4" required="true" /> 
  <FIELD attrname="IMATID" fieldtype="i4" required="true" /> 
  <FIELD attrname="SMATLDESC" fieldtype="string" WIDTH="100" /> 
  <FIELD attrname="SMATSDESC" fieldtype="string" WIDTH="50" /> 
  <FIELD attrname="SMATCODUSER" fieldtype="string" WIDTH="3" /> 
  <FIELD attrname="SMATCODMIN" fieldtype="string" WIDTH="4" /> 
  <FIELD attrname="ICMPSCAID" fieldtype="i4" required="true" /> 
  <FIELD attrname="ISCAID" fieldtype="i4" /> 
  <FIELD attrname="ICMPSCATASS" fieldtype="i4" required="true" /> 
  <FIELD attrname="ICMPSCAINMEDIA" fieldtype="i4" required="true" /> 
  <FIELD attrname="SCMPLDESC" fieldtype="string" WIDTH="100" /> 
  <FIELD attrname="SCMPSDESC" fieldtype="string" WIDTH="50" /> 
  <FIELD attrname="SSCADESC" fieldtype="string" required="true" WIDTH="100" /> 
  <FIELD attrname="ISITID" fieldtype="i4" required="true" /> 
  <FIELD attrname="ICLSSESID" fieldtype="i4" required="true" /> 
  <FIELD attrname="IANAID" fieldtype="i4" /> 
  <FIELD attrname="IANSID" fieldtype="i4" required="true" /> 
  <FIELD attrname="ICLSID" fieldtype="i4" required="true" /> 
  <FIELD attrname="IMATRMAID" fieldtype="i4" required="true" /> 
  <FIELD attrname="IMATINMEDIA" fieldtype="i4" /> 
  <FIELD attrname="ICMPSCAORDINE" fieldtype="i4" required="true" /> 
  <FIELD attrname="IMATRMAPSTORDINE" fieldtype="i4" /> 
  </FIELDS>
  <PARAMS LCID="0" /> 
  </METADATA>
- <ROWDATA>
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026695" ICLSSESID="1000260" IANAID="1013018" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026696" ICLSSESID="1000260" IANAID="1013067" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026700" ICLSSESID="1000260" IANAID="1011698" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026702" ICLSSESID="1000260" IANAID="1013669" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026703" ICLSSESID="1000260" IANAID="1014974" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026704" ICLSSESID="1000260" IANAID="1014996" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026705" ICLSSESID="1000260" IANAID="1015284" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026707" ICLSSESID="1000260" IANAID="1016926" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026714" ICLSSESID="1000260" IANAID="1022398" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026715" ICLSSESID="1000260" IANAID="1023089" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026946" ICLSSESID="1000260" IANAID="1019047" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1027245" ICLSSESID="1000260" IANAID="1024723" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001870" IMATID="1000016" SMATLDESC="DIRITTO" SMATSDESC="DIRITTO" SMATCODUSER="DIR" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1027247" ICLSSESID="1000260" IANAID="1024725" IANSID="38" ICLSID="1001036" IMATRMAID="1000016" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="7" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026695" ICLSSESID="1000260" IANAID="1013018" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026696" ICLSSESID="1000260" IANAID="1013067" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026700" ICLSSESID="1000260" IANAID="1011698" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026702" ICLSSESID="1000260" IANAID="1013669" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026703" ICLSSESID="1000260" IANAID="1014974" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026704" ICLSSESID="1000260" IANAID="1014996" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026705" ICLSSESID="1000260" IANAID="1015284" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026707" ICLSSESID="1000260" IANAID="1016926" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026714" ICLSSESID="1000260" IANAID="1022398" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026715" ICLSSESID="1000260" IANAID="1023089" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026946" ICLSSESID="1000260" IANAID="1019047" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1027245" ICLSSESID="1000260" IANAID="1024723" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001871" IMATID="1000035" SMATLDESC="ECONOMIA POLITICA" SMATSDESC="ECONOMIA POLITICA" SMATCODUSER="ECO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1027247" ICLSSESID="1000260" IANAID="1024725" IANSID="38" ICLSID="1001036" IMATRMAID="1000035" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="8" /> 
  <ROW ICLSSESMATID="1001872" IMATID="1000003" SMATLDESC="STORIA" SMATSDESC="STORIA" SMATCODUSER="STO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026695" ICLSSESID="1000260" IANAID="1013018" IANSID="38" ICLSID="1001036" IMATRMAID="1000003" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="3" /> 
  <ROW ICLSSESMATID="1001872" IMATID="1000003" SMATLDESC="STORIA" SMATSDESC="STORIA" SMATCODUSER="STO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026696" ICLSSESID="1000260" IANAID="1013067" IANSID="38" ICLSID="1001036" IMATRMAID="1000003" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="3" /> 
  <ROW ICLSSESMATID="1001872" IMATID="1000003" SMATLDESC="STORIA" SMATSDESC="STORIA" SMATCODUSER="STO" SMATCODMIN="" ICMPSCAID="2" ISCAID="1" ICMPSCATASS="0" ICMPSCAINMEDIA="1" SCMPLDESC="Orale" SCMPSDESC="O" SSCADESC="Decimale" ISITID="1026700" ICLSSESID="1000260" IANAID="1011698" IANSID="38" ICLSID="1001036" IMATRMAID="1000003" IMATINMEDIA="1" ICMPSCAORDINE="2" IMATRMAPSTORDINE="3" /> 
    </ROWDATA>
  </DATAPACKET>
I cut some lines because "Your message contains 839705 characters. The maximum number of allowed characters is 60000"

Re: dbf to Xml

Posted: Sat Jan 24, 2009 6:09 pm
by Enrico Maria Giordano

Code: Select all

FUNCTION MAIN()

    LOCAL oStream, oRs

    LOCAL i

    oStream = CREATEOBJECT( "ADODB.Stream" )

    oStream:Open()

    oStream:WriteText( MEMOREAD( "TEST.XML" ) )

    oStream:Position = 0

    oRs = CREATEOBJECT( "ADODB.Recordset" )

    oRs:Open( oStream )

    oStream:Close()

    WHILE !oRs:EOF
        FOR i = 0 TO oRs:Fields:Count - 1
            ? oRs:Fields( i ):Value
        NEXT

        ?

        oRs:MoveNext()
    ENDDO

    oRs:Close()

    INKEY( 0 )

    RETURN NIL
EMG

Re: dbf to Xml

Posted: Sun Jan 25, 2009 6:58 am
by Antonio Linares
Otto,

> Timm (http://www.reportdesigner.info/) has a XML-reader class for download on his homepage.

Is it free ?

If yes, could you please copy its source code here ? thanks :-)

Re: dbf to Xml

Posted: Sun Jan 25, 2009 9:14 am
by Otto
Antonio,
The download link is titled as freeware.
Best regards,
Otto

http://www.reportdesigner.info/

Image

Re: dbf to Xml

Posted: Mon Jan 26, 2009 11:03 am
by Silvio
Dear OTTO, Antonio

the class XML of http://www.reportdesigner.info/ is not free !!!!!!!!!!!!!!!!!
I cannot see the source class but only the lib and iclude files.

Re: dbf to Xml

Posted: Thu Jan 29, 2009 11:31 pm
by xProgrammer
Hi Silvio

A function for converting dbf to xml is pretty easy - I don't have my code to hand but could look it out.

You have two choices to make.

You can either use (x)Harbour's built in XML class or just write out as text.

You can either include the structure information as well (great if you then want to reconstruct elsewhere) or just the data contents.

For contents you can just iterate through the records and within each record through the fields and if just writing out as text output "<" + FieldName(i) + ">" + Str( FieldValue(i) + "</" + FieldName(i) + ">". (Some obvious efficiency improvements available if you are handling huge amounts of data.)

Prime with "<record>", add "</record><record>" between records and append "</record>" at the end

If you want to include the structure you can use something like

<xml>
<table>
<tname>Example</tname>
<structure>
<field>
<fname>Surname</fname>
<ftype>C</ftype>
<flen>32</flen>
<fdec>0</fdec>
</field>
<field>
<fname>DOB</fname>
<ftype>D</ftype>
<flen>8</flen>
<fdec>0</fdec>
</field>
</structure>
</table>
<data>


</data>
</xml>

Then it is easy to write a function to reconstruct the table and add the data to the newly created table. This can be very useful as you can use a text editor to modify the data - sometimes doing search and replace etc. before reconstructing it.

This was amongst the first code I wrote when starting out with xHarbour as I needed it to get data into my system. So it wasn't OO. But if I were writing such functionality today it would be. I'm sure a coder of your stature doesn't need my code but if you do want to see it I can look it out.

Re: dbf to Xml

Posted: Fri Jan 30, 2009 8:47 am
by Enrico Maria Giordano
What's wrong with my sample using ADO?

EMG

Re: dbf to Xml

Posted: Sat Jan 31, 2009 3:11 pm
by ermatica

Re: dbf to Xml

Posted: Sat Jan 31, 2009 8:52 pm
by xProgrammer
Hi Enrico

I implied nothing wrong with your solution - but we don't all work in environments with ADO and its quite simple to do natively in (x)Harbour.

In programming there are often multiple ways to achieve a required outcome, and the best way is often site/environment specific. Personally I prefer solutions that make no or minimal assumptions about the operating system and installed software base in which they operate.

This forum is for the free exchange of ideas and I think works best when there is a range of ideas/approaches discussed and members can take away those ideas that are of greatest value to them.