Le 11/3/16 15:36, monty a écrit :
The class comment (and other) could be better; it assumes you already know SAX-style parsing. I will improve it.
I have been working on a tutorial that shows the usage of XMLParser and related libs (like XPath or XMLParserStAX).
EXCELLENT!!!!!!!!
It is being structured like a chapter and formatted with Pillar, so it could go in one of your books (but not PBE, it's too specific for it). Superb. Yes there will be other books :) It would fit perfectly with the PullParser chapter
Could you publish that in the squarebraket github repo? In PharoProgress for example Where can I read it? I'm eager to read it because I want to help this person. I produced a PullXMLParser out of Hernan blog I should add missing examples. https://github.com/SquareBracketAssociates/PharoInProgress/tree/master/XMLPu...
Also, instead of:
h := MySAXHandler new on: FileSystem workingDirectory / 'FILMS.XML'. h parseDocument.
You just want:
result := MySAXHandler parseFileNamed: 'FILMS.XML'.
or if you want to configure it before parsing, you can use an on*: constructor + parseDocument:
result := (MySAXHandler onFileNamed: 'FILMS.XML') "...configure the instance here.." parseDocument.
Yes I did it like that because I had to change the onFileNamed: because I do not know why but in the moose version I used there was a DNU related to asXMLHandleFile or something like that.
Sent: Friday, March 11, 2016 at 7:55 AM From: stepharo <stepharo@free.fr> To: "Pharo Development List" <pharo-dev@lists.pharo.org> Subject: [Pharo-dev] Improving doc of XMLParser
Hi monty
Yesterday one student ask me to import in Moose an XML document. I spent more than 15 min trying....
What would have really help is the following (could you add it into the class comment): Many of the comment do not help because are scarce and not precise enough.
To use a SaxHandler subclass it
SAXHandler subclass: #MySAXHandler instanceVariableNames: '' classVariableNames: '' category: 'MyXMLImporter'
and redefine the method corresponding the notification you want for example:
MySAXHandler>>startElement: aQualifiedName attributes: aDictionary
self halt.
Then to use it simply do
| h | h := MySAXHandler new on: FileSystem workingDirectory / 'FILMS.XML'. h parseDocument. ^ h
Your method startElement: aQualifiedName attributes: aDictionary should get invoked.
I really think that having a tutorial on XML parser ***use*** is cruelly needed.
Stef