Page 1 of 2

PureXML ( PB3.93 and PB4 )

Posted: Tue Mar 01, 2005 5:00 am
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.

Posted: Tue Mar 01, 2005 5:05 am
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...

Posted: Tue Mar 01, 2005 11:35 am
by El_Choni
index? Could yoou tell me more about this, please?

Regards,

Posted: Tue Mar 01, 2005 12:46 pm
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:

Posted: Tue Mar 01, 2005 1:02 pm
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).

Posted: Tue Mar 01, 2005 8:44 pm
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.

Posted: Tue Mar 01, 2005 9:55 pm
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,

PureXML

Posted: Sun Jun 05, 2005 4:07 pm
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>
...

Posted: Sun Jun 05, 2005 5:10 pm
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!

Posted: Fri Jun 10, 2005 12:24 pm
by GeoTrail
How about support for writing XML too ;)

Posted: Wed Oct 19, 2005 9:00 pm
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?

Posted: Thu Oct 20, 2005 7:54 pm
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. :)

Posted: Fri Mar 03, 2006 11:42 am
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!

Posted: Fri Mar 03, 2006 8:22 pm
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 ?

Posted: Sat Mar 04, 2006 1:07 am
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

:)