Should I use the tXML class or XMLDOM to start with XML.
Does someone has an example how to create an xml-file?
Thanks in advance
Otto
//----------------------------------------------------------------------------//
Static Function Atualiza_Grafico()
// Geração do arquivo XML para ser exibido no gráfico
// 19/08/2008 - 19:24:53
//----------------------------------------------------------------------------//
local aCores:={"#AFD8F8","#F6BD0F","#8BBA00","#FF8E46","#008E8E","#D64646","#8E468E","#588526","#B3AA00","#008ED6","#9D080D","#A186BE"}
local aNomes:={"Loja João Paulo | MA","Loja Campina Grande | PB","Loja Campina Grande | PB","Loja Campina Grande | PB" ;
,"Loja Campina Grande | PB","Loja Campina Grande | PB","Loja Campina Grande | PB","Loja Campina Grande | PB" ;
,"Loja Campina Grande | PB","Loja Campina Grande | PB","Loja Campina Grande | PB","Loja Campina Grande | PB"}
local aValor:={"354300","274871","129387","230005","100004","40543","10763","2654","1348","65876","37409","92309"}
XML oXml FILE "..\htdocs\Data.xml" FORMATED CABEC
XML OPEN MARK 'graph' ATTRIB 'caption' VALUE 'Ranking das lojas (mes atual)' ;
ATTRIB 'subCaption' VALUE 'Contratos pagos em Reais' ;
ATTRIB 'showNames' VALUE '1' ;
ATTRIB 'decimalSeparator' VALUE ',' ;
ATTRIB 'thousandSeparator' VALUE '.' ;
ATTRIB 'rotateNames' VALUE '1' ;
ATTRIB 'pieSliceDepth' VALUE '10' ;
ATTRIB 'formatNumberScale' VALUE '0' ;
ATTRIB 'xAxisName' VALUE 'Lojas' ;
ATTRIB 'showAlternateHGridColor' VALUE '1' OF oXml
for nI:=1 to 12
cValor:=aValor[nI]
cCores:=aCores[nI]
XML OPEN MARK 'set' ATTRIB 'name' VALUE aNomes[nI] ;
ATTRIB 'value' VALUE aValor[nI] ;
ATTRIB 'color' VALUE aCores[nI] ;
AUTOCLOSE OF oXml
next
XML CLOSE MARK OF oXml
XML END oXml
return nil
Otto wrote:Hello Derick,
thank you for your help.
Could you please tell me which lib/class and include file I have to link.
Thanks in advance
Otto
*******************************************************************************
* Pruebas para la creacion de fichero xml desde fivewin *
* 01 - 05 - 2002 *
* Enviarme vuestras dudas y sugerencias a fredy@airtel.net *
*******************************************************************************
#include "hbclass.ch"
#include "fileio.ch"
CLASS TXMLWRITE
DATA hFile, lFormated, CtrlCnf, aMark
METHOD New( cOut, cVer, cEncode, cSheet, lFormated, lCabec ) CONSTRUCTOR
METHOD Open( cMark, cType, aAttrib, cTag, lClose, cExt, lCabec )
METHOD Procesar( cText )
METHOD Close()
METHOD End() INLINE FClose( ::hFile )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cOut, cVer, cEncode, cSheet, lFormated, lCabec ) CLASS TXMLWRITE
DEFAULT cVer := "1.0"
DEFAULT cEncode := "ISO-8859-1"
Default lFormated := .F.
Default lCabec := .T.
::lFormated := lFormated
::CtrlCnf := If( ::lFormated, Chr(13)+Chr(10), "" )
::aMark := {}
::hFile := FCreate( AllTrim( cOut ), 0 )
if !lCabec
::Procesar( '<?xml version="' + cVer + '" encoding="' + cEncode + '"?>' )
endif
IF !Empty( cSheet )
::Procesar( '<?xml-stylesheet href="'+ AllTrim( cSheet ) + '" Type="text/xsl"?>' )
END IF
Return( Self )
METHOD Open ( cMark, cType, aAttrib, cTag, lClose, cExt, lCabec ) CLASS TXMLWRITE
Local n, cBuffer
DEFAULT cTag := ""
DEFAULT cType := ""
DEFAULT cExt := ""
DEFAULT lCabec:= .T.
aAdd( ::aMark, cMark )
cBuffer := '<' + cMark
IF Len( ::aMark ) == 1 .and. !lCabec
cBuffer += ' xmlns:dt="urn:schemas-microsoft-com:datatypes"'
END IF
IF !Empty( cType )
cBuffer += ' dt:dt= "' + cType + '"'
END IF
IF Len( aAttrib ) > 0
FOR n := 1 TO Len( aAttrib )
cBuffer += ' '+ aAttrib[n,1] + '="' + aAttrib[n,2] + '" '
NEXT
END IF
cBuffer += '>' + cTag + If( lClose, '</' + cMark + '>' , "" )
::Procesar( cBuffer )
IF lClose
aSize( ::aMark, Len( ::aMark ) -1 )
END IF
Retu Nil
METHOD Close CLASS TXMLWRITE
::Procesar( "</" + ::aMark[ Len( ::aMark ) ] + ">" )
aSize( ::aMark, Len( ::aMark ) -1 )
Retu Nil
METHOD Procesar( cBuffer ) CLASS TXMLWRITE
Local nSpaces := If( ::lFormated, Len( ::aMark ), 0 )
cBuffer := Space( nSpaces )+ cBuffer + ::CtrlCnf
FWrite( ::hFile, cBuffer, Len( cBuffer ) )
Retu Nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 94 guests