finding element by tag in xml

Jim jim.hefferon at gmail.com
Sat Feb 20 16:41:15 EST 2010


On Feb 20, 11:27 am, sWrath swrath <swr... at gmail.com> wrote:
> 2 Questions
>
> 1. Why can't I use dom.getElementsByTagName('book') in #Error 1? How
> do i print the elements ?
>       Error- AttributeError: ElementTree instance has no attribute
> 'getElementsByTagName'

I only see one question here.

I think the error is asserting that your instance of the ET class does
not have such a fcn.  I also do not see it in the ET documentation.
Perhaps you are looking for the XPath support at http://effbot.org/zone/element-xpath.htm
?  Or perhaps you want to make your document dom representation via a
different library?

Jim



More information about the Python-list mailing list