[Tutor] Using xml.etree ElementTree

Juan Christian juan0christian at gmail.com
Wed Oct 8 02:02:45 CEST 2014


On Tue, Oct 7, 2014 at 7:50 PM, Danny Yoo <dyoo at hashcollision.org> wrote:

> Hi Juan,
>
> I think you're looking for:
>
>     http://effbot.org/zone/element.htm#searching-for-subelements
>
> where you should be able to do something like:
>
>     sml._xml.findtext('steamID64')
>
> to get the text "76561198084537782".
>
>
> Let's check:
>
> ###################################################################
> >>> import xml.etree.ElementTree
> >>> import urllib
> >>> f = urllib.urlopen("
> http://steamcommunity.com/profiles/76561198084537782?xml=1")
> >>> tree = xml.etree.ElementTree.ElementTree(file=f)
> >>> tree.findtext('steamID64')
> '76561198084537782'
> ###################################################################
>
>
> Yup, this looks relatively straightforward.  Let us know if you hit any
> snags.
>

Exactly what I needed, thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141007/057f3768/attachment.html>


More information about the Tutor mailing list