I found this function in the xHarbour newsgroup, published by Robert Campsmith to export a dbf to xml. Maybe it´s usefull for somone.
It uses the TXml classes, that come with the xharbour contribution.
// Robert Campsmith
#include "hbXml.ch"
****************************************
FUNCTION DBF2XML( cDataName, cOutName )
*
* Purpose: convert an xBase file to XML
* returns the number of records converted
*
LOCAL aStruct, aField, nFileHandle, nK := 0
LOCAL oXmlDoc, oXmlNode, hAttr, cData
LOCAL OXmlDatabase, oXmlStruct, oXmlRecord, oXmlField
USE (cDataName)
aStruct := DbStruct()
*- Create empty XML document with header
oXmlDoc := TXmlDocument():new( '<?xml version="1.0"?>' )
*- Create main XML node
oXmlDatabase := TXmlNode():new( , "database", { "name" => GetFileName(cDataName) } )
oXmlDoc:oRoot:addBelow( oXmlDatabase )
*- copy structure information to XML
oXmlStruct := TXmlNode():new( , "structure" )
oXmlDataBase:addBelow( oXmlStruct )
FOR EACH aField IN aStruct
*- store field information in XML attributes
hAttr := { "name" => Lower( aField[1] ), ;
"type" => aField[2], ;
"len" => LTrim( Str(aField[3]) ), ;
"dec" => LTrim( Str(aField[4]) ) }
oXmlField := TXmlNode():new(, "field", hAttr )
oXmlStruct:addBelow( oXmlField )
NEXT
*- copy all records to XML
oXmlNode := TXmlNode():new( , "records" )
oXmlDataBase:addBelow( oXmlNode )
BEGIN SEQUENCE
DO WHILE !EOF() .and. RECNO() < 101
hAttr := { "id" => LTrim( Str( Recno() ) ) }
oXmlRecord := TXmlNode():new( , "record", hAttr )
FOR EACH aField IN aStruct
IF aField[2] == "M"
*- Memo fields are written as CDATA
cData := FieldGet( Hb_EnumIndex() )
oXmlField := TXmlNode():new( HBXML_TYPE_CDATA , ;
Lower( aField[1] ), ;
NIL , ;
cData )
ELSE
*- other fields are written as normal tags
cData := FieldGet( Hb_EnumIndex() )
cData := Alltrim( CStr( cData ) )
oXmlField := TXmlNode():new( HBXML_TYPE_TAG , ;
Lower( aField[1] ), ;
NIL , ;
cData )
ENDIF
*- add field node to record
oXmlRecord:addBelow( oXmlField )
NEXT
*- add record node to records
oXmlNode:addBelow( oXmlRecord )
SKIP
ENDDO
*- create XML file
nFileHandle := FCreate( cOutName )
*- write the XML tree, this takes a long time.
oXmlDoc:write( nFileHandle, HBXML_STYLE_INDENT )
*- close files
FClose( nFileHandle )
END // SEQUENCE
CLOSE (cDataname)
RETURN( nK )
*