FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A XMLDOM simple sample
Posts: 310
Joined: Sun Jan 08, 2006 10:09 PM
A XMLDOM simple sample
Posted: Fri May 23, 2008 03:29 AM
Hi,

This is my simple test using XMLDOM:

I have instaled Windows Server 2003 SP2 e .NET 1.0 e 2.0 and SOAP Toolkit 3.0.

#include "FiveWin.ch"

Function main()

    local RespText, objXMLHTTP

    oXMLDoc := TOLEAUTO():New("Microsoft.XMLDOM")
      
    // Allow the document to complete loading
    oXMLDoc:async := .f.

    lSuccess := oXMLDoc:load( "books.xml" )

    x := oXMLDoc:getElementsByTagName( "book" )
    y := oXMLDoc:getElementsByTagName( "author" )

    for i = 1 to x:length
        agendamentoDetails := x
        ? agendamentoDetails:Item(i-1):NodeName + " = " + agendamentoDetails:Item(i-1):Text
        ? y:Item(i-1):Text
    next

   return nil


A XML table:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
   <book category="COOKING">
      <title lang="en">Everyday Italian</title>
      <author>Giada De Laurentiis</author>
      <year>2005</year>
      <price>30.00</price>
   </book>
   <book category="CHILDREN">
      <title lang="en">Harry Potter</title>
      <author>J K. Rowling</author>
      <year>2005</year>
      <price>29.99</price>
   </book>
   <book category="WEB">
      <title lang="en">XQuery Kick Start</title>
      <author>James McGovern</author>
      <year>2003</year>
      <price>49.99</price>
   </book>
   <book category="WEB">
      <title lang="en">Learning XML</title>
      <author>Erik T. Ray</author>
      <year>2003</year>
      <price>39.95</price>
   </book>
   <book>
      <title lang="en">Learning XML</title>
      <author>Erik T. Ray</author>
      <year>2003</year>
      <price>39.95</price>
   </book>
</bookstore>


PS: Not tested in other Windows versions.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
A XMLDOM simple sample
Posted: Fri May 23, 2008 11:00 AM

Rochinha,

Thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: A XMLDOM simple sample
Posted: Thu May 29, 2008 12:39 PM
Rochinha wrote:Hi,

This is my simple test using XMLDOM:

I have instaled Windows Server 2003 SP2 e .NET 1.0 e 2.0 and SOAP Toolkit 3.0.

#include "FiveWin.ch"

Function main()

    local RespText, objXMLHTTP

    oXMLDoc := TOLEAUTO():New("Microsoft.XMLDOM")
      
    // Allow the document to complete loading
    oXMLDoc:async := .f.

    lSuccess := oXMLDoc:load( "books.xml" )

    x := oXMLDoc:getElementsByTagName( "book" )
    y := oXMLDoc:getElementsByTagName( "author" )

    for i = 1 to x:length
        agendamentoDetails := x
        ? agendamentoDetails:Item(i-1):NodeName + " = " + agendamentoDetails:Item(i-1):Text
        ? y:Item(i-1):Text
    next

   return nil


A XML table:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
   <book category="COOKING">
      <title lang="en">Everyday Italian</title>
      <author>Giada De Laurentiis</author>
      <year>2005</year>
      <price>30.00</price>
   </book>
   <book category="CHILDREN">
      <title lang="en">Harry Potter</title>
      <author>J K. Rowling</author>
      <year>2005</year>
      <price>29.99</price>
   </book>
   <book category="WEB">
      <title lang="en">XQuery Kick Start</title>
      <author>James McGovern</author>
      <year>2003</year>
      <price>49.99</price>
   </book>
   <book category="WEB">
      <title lang="en">Learning XML</title>
      <author>Erik T. Ray</author>
      <year>2003</year>
      <price>39.95</price>
   </book>
   <book>
      <title lang="en">Learning XML</title>
      <author>Erik T. Ray</author>
      <year>2003</year>
      <price>39.95</price>
   </book>
</bookstore>


PS: Not tested in other Windows versions.


Hola Rochina,

Precisamente estoy necesitando trabajar con xmldom y web services, tu ejemplo es muy interesante para empezar, pero al compilarlo me da este error:
UNRESOLVED EXTERNAL "_HB_FUN___DBGENTRY" ....
que puede causarlo?
Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
A XMLDOM simple sample
Posted: Thu May 29, 2008 12:49 PM

Me respondo a mi mismo....

Debe compilarse junto a la lib de xharbour debug.lib.

Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 310
Joined: Sun Jan 08, 2006 10:09 PM
A XMLDOM simple sample
Posted: Fri May 30, 2008 09:29 PM

Jose,

The sample work with you?

See other sample in http://www.5volution.com/forum/xmlmerge.zip

This sample merge a XML data with a Word document via OLE and XMLDOM.

Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
A XMLDOM simple sample
Posted: Sat May 31, 2008 01:08 AM
Rochinha wrote:Jose,

The sample work with you?

See other sample in http://www.5volution.com/forum/xmlmerge.zip

This sample merge a XML data with a Word document via OLE and XMLDOM.


Si, el ejemplo anterior me ha funcionado perfectamente, inclusive modificandolo un poco he logrado ver en un browse la información e imprimirla con la clase treport.

Probaré este que me sugieres y luego te cuento.

Muchas gracias por tus aportes.
Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
A XMLDOM simple sample
Posted: Sun Jun 01, 2008 11:57 PM
Rochinha wrote:Jose,

The sample work with you?

See other sample in http://www.5volution.com/forum/xmlmerge.zip

This sample merge a XML data with a Word document via OLE and XMLDOM.


Estoy teniendo este error con el xmlmerge.exe:

Application
===========
Path and name: C:\xmlmerge\XMLMERGE.EXE (32 bits)
Size: 1,111,552 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 06/01/08, 20:55:33
Error description: Error BASE/1081 Argument error: +
Args:
[ 1] = C C:\xmlmerge\
[ 2] = U

Stack Calls
===========
Called from: => OLEMERGE(42)

System
======
CPU type: Intel(R) Pentium(R) 4 CPU 3.06GHz 3066 Mhz
Hardware memory: 504 megs

Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %

Compiler version: Harbour Alpha build 45.0 Intl. (Flex)
Windows version: 5.1, Build 2600 Service Pack 2

Windows total applications running: 0

Variables in use
================
Procedure Type Value
==========================
OLEMERGE
Local 1: U
Local 2: U
Local 3: L .T.
Local 4: C "C:\xmlmerge"
Local 5: U
Local 6: U
Local 7: U
Local 8: U
Local 9: U
Local 10: U
Local 11: U
Local 12: U
Local 13: C "C:\xmlmerge"
Local 14: U
Local 15: U
Local 16: N 0

Linked RDDs
===========
DBF
DBFFPT
DBFBLOB
DBFNTX

DataBases in use
================

Classes in use:
===============
1 HBCLASS
2 ERROR
3 HBOBJECT
4 TREG32

Memory Analysis
===============
107 Static variables

Dynamic memory consume:
Actual Value: 0 bytes
Highest Value: 0 bytes

Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 310
Joined: Sun Jan 08, 2006 10:09 PM
A XMLDOM simple sample
Posted: Mon Jun 02, 2008 02:59 AM
Jose,

see how to use XMLMerge.exe:

XMLMerge arquivo.doc arquivo.xml

Example:
XMLMerge teste.rtf teste.xml

TESTE.XML code:
<?xml version="1.0" encoding="ISO-8859-1"?> 
<olemerge> 

   <campos>nome</campos> 
   <campos>email</campos> 
   <campos>site</campos> 

   <dados>Jose Carlos da rocha</dados> 
   <dados>irochinha@itelefonica.com.br</dados> 
   <dados>http://www.5volution.com</dados> 

</olemerge>


Open a new word document and put this lines:
Hello,

My name is &#NOME#& and my email is &#EMAIL#&

Visite my website at &#SITE#&.


Save with name TESTE.DOC or TESTE.RTF and run the XMLMerge.exe.
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
A XMLDOM simple sample
Posted: Mon Jun 02, 2008 05:59 PM

Hello Rochinha,

I would like to have a look on your xmldom example but I get this error:

Path and name: C:\FWH\samples\xmldom\XMLMERGE.EXE (32 bits)
Size: 1,111,552 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 06/02/08, 19:57:59
Error description: Error BASE/1081 Argument error: +
Args:
Regards,
Otto

Posts: 310
Joined: Sun Jan 08, 2006 10:09 PM
A XMLDOM simple sample
Posted: Tue Jun 03, 2008 12:35 PM
Otto,

The XMLMerge is a command line tool.

You need pass two parameters:

XMLMerge arquivo.doc arquivo.xml

Otherwise, i rebuild the XMLMerge, download it in http://www.5volution.com/forum/xmlmerge.zip

Continue the discussion