Stef, I hope/plan to be able to add that to my talk at the pharo days. Sven
On 11 Mar 2016, at 13:55, stepharo <stepharo@free.fr> wrote:
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