Nice!
Thanks Kent Bernard On 9/30/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Oh, what if you try > > class MyBeautifulSoup(BeautifulSoup.BeautifulStoneSoup): > NESTABLE_BLOCK_TAGS = ['sceneobject', 'parameters', 'parameter', 'shader'] > NESTABLE_TAGS = buildTagMap([], NESTABLE_BLOCK_TAGS) > > > Bernard Lebel wrote: > > I know I should be doing that. But somehow it doesn't work (ie I keep > > getting mangled XML tree). > > > > Bernard > > > > > > > > On 9/30/05, Kent Johnson <[EMAIL PROTECTED]> 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. > >> > >>Kent > >> > >>_______________________________________________ > >>Tutor maillist - Tutor@python.org > >>http://mail.python.org/mailman/listinfo/tutor > >> > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor