[Tutor] Problem with BeautifulSoup

Bernard Lebel 3dbernard at gmail.com
Fri Sep 30 18:05:02 CEST 2005


Nice!


Thanks Kent
Bernard



On 9/30/05, Kent Johnson <kent37 at tds.net> 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 <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.
> >>
> >>Kent
> >>
> >>_______________________________________________
> >>Tutor maillist  -  Tutor at python.org
> >>http://mail.python.org/mailman/listinfo/tutor
> >>
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list