Am 29.05.2010 00:48 schrieb Steve Clement: > ... > <head py:match="item.tag == 'head'"> > <?python > title=item.find('title') > if title is not None: > item.remove(title) > title = title.text > ?> > <title> > Kieser Training Customer Portal > <span py:strip="" py:if="title"> - ${title}</span> > </title> > ... > > if I compile this and open my page in the web browser I get the > following error: > ... > AttributeError: 'Element' object has no attribute 'find' > > As far as I can tell the code that has been generated is faulty. You > cannot use .find on the list that has been generated.
Yes, the kid.Element does not support find(). You can do something like this, however: <?python titles = filter(lambda item: item.tag == 'title', item) if titles: title = titles[0] item.remove(title) title = title.text ?> Another solution is this: <head py:match="item.tag == 'head'"> <title py:for="title in item" py:if="title.tag == 'title'"> Kieser Training Customer Portal - <span py:replace="title.text"/> </title> ... </head> Or, you can use nested matches: <head py:match="item.tag == 'head'"> <title py:match="item.tag == 'title'"> Kieser Training Customer Portal - <span py:replace="item.text"/> </title> ... </head> -- Christoph ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ kid-template-discuss mailing list kid-template-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kid-template-discuss