Ecere SDK/eC Forums
http://ec-lang.org/community/
Print view

XMLParser
http://ec-lang.org/community/viewtopic.php?f=15&t=70
Page 1 of 1
Author:  fedor_bel [ Thu Apr 08, 2010 4:22 am ]
Post subject:  XMLParser

Dear Jerome,
Is the XMLParser in the extras section complete? It seem to be a work in progress. I have found some unclear moments in it for me when trying to use it and debugging through it. It calls ProcessKeyword for opening and closing tags, sending just the tag name as a parameter. What is a possible use for it?
Does it understand the starting <?xml version="1.0" encoding="utf-8" standalone="no"?> line? Should not we have a more useful and powerful parser? And the very last question, which started to bother me recently: why would we need to wright our own parser in the first place, when this task has already been completed by numerous other programmers in the world? I dont like reinventing the bycicle.
Cheers,
Fedor
Author:  jerome [ Mon Apr 12, 2010 9:42 pm ]
Post subject:  Re: XMLParser

Hi Fedor, sorry for the late reply.

The XMLParser (and everything else in the extras) is what it is.
It comes with no warranty of completeness, usability or fitness of purpose of any kind (in fact the same applies for the whole SDK, but even more so for the extras).

If you look at samples/net/XMLSample you will find a sample use for it.
I'm not a big fan of XML myself, I much prefer JSON which I adopted for the IDE's project files (the new .epj version).

By calling GetWord() and looking at the 'word' string you can go through the various elements inside the tags.

I guess you simply missed that sample (fairly enough, having no indication about it :) )
Perhaps we should point to it in the XMLParser.ec file.

The reason for having our own parser is because it is a very simple task that can be accomplished in just a few lines of eC code, and mainly because I didn't want to rely on anyone else's code.
It is up to you to use whichever parser you like (e.g. libexpat is a decent one), or write your own more powerful XML parser, based on XMLParser.ec or from scratch.

As for reinventing the bicycles, we humans really don't invent anything. We just discover things that the Universe put there for us to discover and guided us to discover.

Cheers :)

Jerome
All times are UTC-05:00 Page 1 of 1