[Tutor] Problem with BeautifulSoup
3dbernard at gmail.com
Fri Sep 30 17:40:19 CEST 2005
I know I should be doing that. But somehow it doesn't work (ie I keep
getting mangled XML tree).
On 9/30/05, Kent Johnson <kent37 at tds.net> wrote:
> 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.
> Tutor maillist - Tutor at python.org
More information about the Tutor