[Gambas-devel] gbXML v0.0.9 - RFC

Karol Tomala ktomala at ...166...
Mon Oct 11 11:39:28 CEST 2004


Hello everybody!

Since there was some interest in my XML classes for Gambas I'm posting
the code here. It's released under LGPL v2 so you can use it also in
your commercial programs, as long as you give back the code for gbXML to
the community. 

The package consists of three classes: cXMLDoc, cXMLTag and cXMLTagOpt.
The first one manages document, second one manages tag operations and
the last one manages tag options. The API is currently stabilized, so
you can use it. I have taken some tests and I know that these classes
will have problems with documents larger than 1MB. Also document loading
is done quite quickly and it should be reconsidered for binary input (so
you can try to load XML documents from other sources like sockets). 

There is docs.html file, but it's pretty outdated and incomplete. Take a
look at Module1 file which has some clues about how to use these
classes.

!!! THIS gbXML classes should be considered as INCOMPLETE! !!! It has
some functionality and is currently usable for small and medium sized
documents.

And here is the example how to use these classes:

--- snip ---

DIM xdc AS cXMLDoc	'define xdc as new class
DIM dumdepth AS Integer 'define dummy depth

xdc = new cXMLDoc	'create object

'set filename of the document
xdc.SetFilename("/home/wolverine/documents/content.xml")

'Try to load document
IF xdc.Load() THEN
  'If successful show debugging output
  PRINT xdc.DebugOutput()
ELSE
  PRINT "failed"
  RETURN
ENDIF

'Set pointer to fifth tag in the document
xdc.SetPtr(10)

'Show currently pointed tag
PRINT xdc.GetPtrTag().Construct()

'Get depth of currently pointed tag
dumdepth = xdc.GetPtrTag().GetDepth()

'Check depth
IF dumdepth >= 2 THEN
  'Set pointer to parent tag of currently pointed tag
  xdc.SetPtr(xdc.GetParent())
  'Show tag
  PRINT xdc.GetPtrTag().Construct()
  'Try to show closing tag number of currently pointed tag
  PRINT xdc.FindClosing()
  'Show closing tag
  PRINT xdc.GetTag(xdc.Findclosing()).Construct()
ENDIF

'Show whole document
PRINT xdc.Output()

--- snip ---

This is how to use these classes. It should be simple to use and I hope
that you can understand basic XML document management. Almost every
function in these classes return either result or NULL on failure.
That's why you have to distinct between function result types. You will
have to browse through these classes and look at functions because there
are some fancy methods to handle documents.

I'm waiting for some feedback and propositions of improvements, patches
for things in TODO list and so on. I don't have much time now to work on
these, but if I get enough feedback and somebody will find these classes
useful I will try to work on them.

Greetings,
-- 
Karol Tomala [Network administrator]
TGC Group / Contract Administration Sp. z o.o.
Mail: ktomala (at) tgc (dot) pl
WWW: www.tgc.pl | www.bakertilly.pl
Phone: (+48 22) 6533833
Mobile: (+48) 693290300
Address: ul. Królewska 27 00-060 Warsaw Poland
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gbxml.tar.gz
Type: application/x-compressed-tar
Size: 18803 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20041011/954ca97a/attachment.bin>


More information about the Devel mailing list