[Tutor] Problem with BeautifulSoup

Kent Johnson kent37 at tds.net
Fri Sep 30 17:32:29 CEST 2005

Bernard Lebel wrote:
> Hi Kent,
> Well I have decided to get this sorted once and for all. Not that I
> don't like ElementTree, but the fack is that BeautifulSoup uses a near
> identical syntax to the 3D application SDK's object model I'm using it
> with, making interaction between the 3D and the XML extremely
> transparent. Anyway, here is what I did.
> I simply modified the BeautifulSoup class, and added my own nestable
> tags to the list of NESTABLE_BLOCK_TAGS:
> NESTABLE_BLOCK_TAGS = ['blockquote', 'div', 'fieldset', 'ins', 'del']
> became
> NESTABLE_BLOCK_TAGS = ['blockquote', 'div', 'fieldset', 'ins', 'del',
> 'sceneobject', 'parameters', 'parameter', 'shader']

For your purposes I think you should be able to just do
class MyBeautifulSoup(BeautifulSoup.BeautifulStoneSoup):
    NESTABLE_BLOCK_TAGS = ['sceneobject', 'parameters', 'parameter', 'shader']

since presumably you don't need special handling for 'ol', 'ul', etc that BeautifulSoup has.

In any event there is no need to modify BS, better to make your own BSS subclass.


More information about the Tutor mailing list