A XMLDOM simple sample

A XMLDOM simple sample

Postby Rochinha » Fri May 23, 2008 3: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.

Code: Select all  Expand view
#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  Expand view
<?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.
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby Antonio Linares » Fri May 23, 2008 11:00 am

Rochinha,

Thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: A XMLDOM simple sample

Postby jose_murugosa » 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.

Code: Select all  Expand view
#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  Expand view
<?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
FWH + Harbour + Bcc7. Una seda!
User avatar
jose_murugosa
 
Posts: 1144
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Postby jose_murugosa » 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
FWH + Harbour + Bcc7. Una seda!
User avatar
jose_murugosa
 
Posts: 1144
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Postby Rochinha » Fri May 30, 2008 9: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.
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby jose_murugosa » Sat May 31, 2008 1: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
FWH + Harbour + Bcc7. Una seda!
User avatar
jose_murugosa
 
Posts: 1144
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Postby jose_murugosa » 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
FWH + Harbour + Bcc7. Una seda!
User avatar
jose_murugosa
 
Posts: 1144
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Postby Rochinha » Mon Jun 02, 2008 2:59 am

Jose,

see how to use XMLMerge.exe:

XMLMerge arquivo.doc arquivo.xml

Example:
XMLMerge teste.rtf teste.xml

TESTE.XML code:
Code: Select all  Expand view
<?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  Expand view
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.
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby Otto » Mon Jun 02, 2008 5: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
User avatar
Otto
 
Posts: 6003
Joined: Fri Oct 07, 2005 7:07 pm

Postby Rochinha » 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
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests