PureXML ( PB3.93 and PB4 )

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

PureXML ( PB3.93 and PB4 )

Post by Flype »

Good news...
I share a new userlibrary i made to parse XML file as easy as possible.

You can download it here :
http://www.penguinbyte.com/apps/pbwebst ... ureXML.zip

And here is the help file :

Code: Select all

----------------------------------------------------------------------
 Name       PureXML
 Version    1.0 Beta
 Date       Feb. 2005
            
 Descr.     A Purebasic XML Userlibrary based on the 'xmlparser.dll'
            Written by Philippe Carpentier - flype@altern.org
            
 Compil.    Compiled with Purebasic 3.93 Beta 3
            UserLibrary made with TailBite 1.2 Beta 2
            Tested on Windows 98, 2000, XP
            
 Requir.    You must place the xmlparser.dll in same directory
----------------------------------------------------------------------

Main functions :

  Result.b = PureXML_ParseFile(xmlFile.s)
  Result.b = PureXML_ParseString(xmlString.s)
  Result.s = PureXML_LastError()

The goal of this UserLib is two read XML data from
a file or from a string. Here are the functions :-)

----------------------------------------------------------------------

Callback functions ( no return value ) :

  PureXML_SetOpenHandler(*funcPtr.l)
  PureXML_SetCloseHandler(*funcPtr.l)
  PureXML_SetDataHandler(*funcPtr.l)
  PureXML_SetCommentHandler(*funcPtr.l)
  PureXML_SetInvalidHandler(*funcPtr.l)

You should set those functions to catch XML  events.
Then you can easily process what you need for each tag name.

;-
Procedure MyXML_o()
  debug PureXML_Name()
EndProcedure

PureXML_SetOpenHandler(@MyXML_o)
;-

----------------------------------------------------------------------

Properties functions :

  Result.s = PureXML_Name()
  Result.s = PureXML_Data()
  Result.s = PureXML_Attr(attrName.s)

This help you process data from XML tags.
  
  An example :

  <software id='0' name='purebasic'>
    A great 'not so basic' language
  </software>
  
  PureXML_Name()       >>> "software"
  PureXML_Data()       >>> "  A great 'not so basic' language"
  PureXML_Attr("id")   >>> "0"
  PureXML_Attr("name") >>> "purebasic"

----------------------------------------------------------------------

Have fun
flype - 2005
It is beta state - So please report bugs...
Best regards.
Last edited by Flype on Sat Mar 04, 2006 1:19 am, edited 1 time in total.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

By the way, TaileBite 1.2 Beta 2 used with Purebasic 3.93 Beta 3 reports me a syntax error when i click on the 'Check for errors' buttons. But no problem, TailBite compile it anyway :)
Seems to be the same index problem than jaPBe...
Last edited by Flype on Tue Mar 01, 2005 12:48 pm, edited 1 time in total.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

index? Could yoou tell me more about this, please?

Regards,
El_Choni
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

The list of the return errors codes is different from previous version of Purebasic because of new linkers.
So you have to update your messages return code list ( if i have well understood - see jaPBe last posts ).

:idea:
Or maybe it is because the PureXML userlibrary make use of the XMLPARSER & the xmlparser.lib created using DLL Importer.
So in my internal code i use some functions like XMLzGetTag_(*node)...
Just wondering... if you need the PureXML source code for debugging say me hello :wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Well, I'll check that. But the text that appears when you run TailBite is the text that the compiler outputs. It's PBCompiler saying "Syntax error", not TailBite.

Weird anyway, so I'll have a look (feel free to send me the source for checking).
El_Choni
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Here is the TailBite Manager Error requester :
Image

And i notice that it is the same with another userlib test...
not only on my PureXML userlib.

It's only a problem which occur in TBManager by clicking on 'Check for errors'. Even with the brand new Purebasic 3.93 Full.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Fixed, thank you for the report, Flype. TailBite is not yet fully compatible with 3.93, though. I need to fix the array/linked lists handling.

EDIT: Ok, I misunderstood something; there's no problem with TailBite and PB 3.93 (yet ;), but you need to recompile UserLibraries made before PureBasic 3.93 in order to get them working now. I think. Or maybe only if you use Arrays or Linked Lists.

Regards,
El_Choni
Rollo
New User
New User
Posts: 3
Joined: Sun Nov 07, 2004 12:50 pm
Location: Germany

PureXML

Post by Rollo »

Hi everyone,
i habe a problem with PureXML-Lib.

The PureXML-Userlib is very usefull and easy to use.
But i have some problems to read a xml/rss file.

The call

Code: Select all

PureXml_ParseFile(pRSS_URL$)
is False when i read a file with a

Code: Select all

<![CDATA[ ... ]]> 
statement.
=>Error-Msg: unreadable character or so...

In the XML-definition (http://www.w3.org/TR/2000/REC-xml-20001006) then CDATA-sections is special for unreadable characters.

Can someone help me to solve this problem?
Thank you.

Example:

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="0.91">
<channel>
<title>Handelsblatt.com</title>
<link>http://www.handelsblatt.com</link>
<description>Handelsblatt.com</description>
<language>de</language>
 <item>
<title>
<![CDATA[ 
Wall Street schließt gemischt
]]>
</title>
<link>http://www.handelsblatt.com/hbiwwwangebot/fn/relhbi/sfn/buildhbi/cn/bp_artikel/docid/901749/STRUCID/200007/PAGEID/200009/index.html</link>
<description>
<![CDATA[ 
Rubrik: Börse
Geschrieben am 20.05.2005 um 22:24
  ]]>
</description>
</item>
...
PB3.93; win98
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

Is the XMLParser library cross-platform? Are there versions for Linux and MacOS X ?

If so, by using Callbacks you're limiting it to Windows - if the XMLParser is available on those other platforms, would it be possible to make a cross-platform version of the PureXML-Lib available?

Thanks!
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

How about support for writing XML too ;)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

This looks pretty sweet, from the sample in the post, it looks like it automatically reads the schema thats in the XML already ... if so, that's awesome ...

One question though, any chance you can remove the dependency (DLL) for this userlib?
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

you are true.
the <![CDATA[ ... ]]> are making trouble with the provided dll. i know that but i can't modify the dll for this. :cry: reading rss was the goal of this userlib.
but now that there is PBOSL / MSXML i'm happy 'cause it works so well. :)
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
kenjig
New User
New User
Posts: 3
Joined: Wed Mar 01, 2006 4:59 am

Post by kenjig »

Hi Flype,

thanks for the lib, but I seem to be having trouble running PureXML on PB4. Works without problem on 3.94.

Will this library be updated in the near future?

Thanks!
PureBasic 4.00 Beta 5 / PureVisionXP 4.00
Intel(R) Pentium(R) 4 CPU 3.00GHz / 1.00 GB RAM / Albatron GeForce 6600 256MB DDR 16x PCI Express Card w/TV
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Hello,

I'm sorry but No i don't think so and the reason is simple :

there's the MSXML3 userlibrary of the PBOSL collection which is a good choice, believe me.
The Microsoft's one is powerful and works very well even with CDATA section of course.

http://pbosl.purearea.net/index.php?site=Libs

But maybe...
I will have a look just to test PB4 beta5... :twisted:


By the way do you have / do you want the source of PureXML ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

OK, finally, i rewrite PureXML for PB4.0, and it works well, even faster.

But this time, it is no more a userlibrary.
This is a simple include file waiting for the next TailBite release.

Feel free to do what you want with the source.

File:1->PureXML_0.2_Source_PB4.zip
Image

:)
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply