[Tutor] Problem with BeautifulSoup

Bernard Lebel 3dbernard at gmail.com
Fri Sep 23 21:15:14 CEST 2005


Hi grouchy,

I seem to have found the problem. Somehow, it seems BeautifulSoup
doesn't like nested tags of the same name. For instance, I had this
tree:

<parameters>
   <parameter...>
      <fcurve>
         <parameters>
            <parameter...>
            </parameter>
         </parameters>
      </fcurve>
   </parameter>
</parameters>


Printing the entire tree in the command line shell showed some weird
rearrangements of the tree in these areas, where tags would show up in
different order, and there were a few black lines (there are none in
my xml file beyond the first tree tag). Chaing the second second of
<parameters><parameter> combination to
<fcurveparameters><fcurveparameter> seem to have solved the issue.

This sounds to me like a limitation..... oh well.


Thanks!
Bernard



On 9/23/05, grouchy <grouch at gmail.com> wrote:
> Hi Bernard,
>
> Not much of an answer, but I printed out your snippet with prettify() to see
> how it was being parsed, and either the XML is funny, or Beautiful Soup is
> :)
>
> >>> from BeautifulSoup import BeautifulStoneSoup as BSS
> >>> soup = BSS(xml)
> >>> print soup.prettify()
>
>  <parameter scriptname="posx"
> fullname="Model.Camera_anim.kine.local.posx"
> type="Parameter" sourceclassname="FCurve">
>   <fcurve plotted="False">
>    <parameters>
>    </parameters>
>   </fcurve>
>  </parameter>
>  <parameter scriptname="extrapolation">1
>  </parameter>
>  <parameter scriptname="interpolation">3
>  </parameter>
>  <parameter scriptname="highclamp">1.79769313486e+308
>  </parameter>
>  <parameter scriptname="locked">False
>  </parameter>
>  <parameter scriptname="lowclamp">- 1.79769313486e+308
>  </parameter>
>  <parameter scriptname="nokeyvalue">7.64880829803
>  </parameter>
>  <parameter scriptname="si3dstyle">False
>  </parameter>
>  <parameter scriptname="type">20
>  </parameter>?
> >>>
>
>
>
>
> On 9/23/05, Bernard Lebel <3dbernard at gmail.com> wrote:
> >
> > Hello,
> >
> > I have this set of XML tags:
> >
> >
> > <parameter scriptname="posx"
> > fullname=" Model.Camera_anim.kine.local.posx"
> type="Parameter"
> > sourceclassname="FCurve">
> >        <fcurve plotted="False">
> >           <parameters>
> >                  <parameter
> scriptname="extrapolation">1</parameter>
> >                  <parameter
> scriptname="interpolation">3</parameter>
> >                  <parameter
> scriptname="highclamp">1.79769313486e+308</parameter>
> >                  <parameter
> scriptname="locked">False</parameter>
> >                  <parameter
> scriptname="lowclamp">-1.79769313486e+308</parameter>
> >                  <parameter
> scriptname="nokeyvalue">7.64880829803</parameter>
> >                  <parameter
> scriptname="si3dstyle">False</parameter>
> >                  <parameter
> scriptname="type">20</parameter>
> >           </parameters>
> >        </fcurve>
> > </parameter>
> >
> >
> > This set of tags is nested deep few levels of tags. When I get the
> > fcurve tag, all I get is an empty tag. ie:
> >
> >
> > oXMLFcurve = oXMLParameter.fcurve
> > print str(oXMLFcurve)
> >
> >
> > Outputs:
> >
> >
> > <fcurve plotted="False">
> > </fcurve>
> >
> >
> > Normally it would print all the content of the tag, but it's not....
> > Any suggestion or pointer would be welcome!
> >
> >
> > Thanks
> > Bernard
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>


More information about the Tutor mailing list