Page 1 of 1

A XMLDOM simple sample

Posted: Fri May 23, 2008 3:29 am
by Rochinha
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.

Code: Select all

#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:

Code: Select all

<?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.

Posted: Fri May 23, 2008 11:00 am
by Antonio Linares
Rochinha,

Thanks! :-)

Re: A XMLDOM simple sample

Posted: Thu May 29, 2008 12:39 pm
by jose_murugosa
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.

Code: Select all

#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:

Code: Select all

<?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?

Posted: Thu May 29, 2008 12:49 pm
by jose_murugosa
Me respondo a mi mismo....

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

Posted: Fri May 30, 2008 9:29 pm
by Rochinha
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.

Posted: Sat May 31, 2008 1:08 am
by jose_murugosa
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.

Posted: Sun Jun 01, 2008 11:57 pm
by jose_murugosa
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

Posted: Mon Jun 02, 2008 2:59 am
by Rochinha
Jose,

see how to use XMLMerge.exe:

XMLMerge arquivo.doc arquivo.xml

Example:
XMLMerge teste.rtf teste.xml

TESTE.XML code:

Code: Select all

<?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:

Code: Select all

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.

Posted: Mon Jun 02, 2008 5:59 pm
by Otto
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

Posted: Tue Jun 03, 2008 12:35 pm
by Rochinha
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