Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 24, 2018 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/b8773498c009d56a18c53de9bb1106fa to your computer and use it in GitHub Desktop.
Save Fhernd/b8773498c009d56a18c53de9bb1106fa to your computer and use it in GitHub Desktop.
Lectura de un documento XML en Python. OrtizOL.
from urllib.request import urlopen
from xml.etree.ElementTree import parse
# Descarga del archivo XML:
texto_xml = urlopen('http://planet.python.org/rss20.xml')
# Representación como documento XML:
doc_xml = parse(texto_xml)
# Recorrido del contenido del documento XML:
for elemento in doc_xml.iterfind('channel/item'):
print(elemento.findtext('title'))
print(elemento.findtext('pubDate'))
print(elemento.findtext('link'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment