Today's Smalltalk Daily looks at parsing XML when the XML has errors.
To show the problem and solution, I downloaded an RSS feed, inserted some illegal characters, and saved the file. Then I used this code:
"Standard Parser"
content := 'badRss.xml' asFilename contentsOfEntireFile.
parser := XML.XMLParser new.
parser validate: false.
parser parse: content readStream.
"Tolerant Parser, loaded from public store"
parser := TolerantXML.TolerantParser new.
parser validate: false.
parser parse: content readStream
To watch, click on the viewer below:
If you have trouble viewing that directly, you can click here to download the video directly
You can also watch it on YouTube:
Technorati Tags:
smalltalk, xml, error handling