W P
unread,Mar 14, 2011, 10:16:37 AM3/14/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to beautifulsoup
I have to parse an XML tree that frequently using a tag named 'name'.
I was wondering what the best way to select these elements is, but see
two contradicting statements in the Beautiful Soup documentation:
> Previous versions of Beautiful Soup had methods like first,
fetch, and fetchPrevious. These methods are sitll there, but they're
deprecated, and may go away soon.
> If you're looking for tag names that aren't valid Python
identifiers (like hyphenated-name), you need to use first.
I know the tag name 'name' is a valid Python identifier, but I can't
use it to select the tag because Beautiful Soup uses it as an
attribute of the element instance. I have been using .first('name')
to select it, but what should I do if .first() goes away in a future
release? I have no control over the XML schema of the document I am
parsing, it is XML that is returned from an external web service.