XMLDOM or TXML

XMLDOM or TXML

Postby Otto » Thu Oct 02, 2008 5:37 pm

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
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby Kleyber » Thu Oct 02, 2008 5:53 pm

Otto,
Code: Select all  Expand view
//----------------------------------------------------------------------------//
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


Maybe this helps.

Best Regards,
Kleyber Derick

FWH / xHb / xDevStudio / SQLLIB
User avatar
Kleyber
 
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Postby Otto » Thu Oct 02, 2008 6:36 pm

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
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: XMLDOM or TXML

Postby wmormar » Thu Oct 02, 2008 8:29 pm

Otto,

revisa CODIGO-BASE

ahí he colgado una LIB para el manejo de XML

espero te ayude
William, Morales
Saludos

méxico.sureste
User avatar
wmormar
 
Posts: 1074
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Postby Kleyber » Thu Oct 02, 2008 8:47 pm

Hello Otto,

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


Just the TXMLWRITE class made by Fredy. This is the code (there are some changes made by me).


Code: Select all  Expand view
*******************************************************************************
*            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
Kleyber Derick

FWH / xHb / xDevStudio / SQLLIB
User avatar
Kleyber
 
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Postby Otto » Thu Oct 02, 2008 9:14 pm

Derick, thank you. Now it is working.

Best regards,
Otto

William, thank you for the info.
I will have a look at CODIGO-BASE, too.

Regards,
Otto
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 77 guests

cron