Created
July 24, 2018 14:32
-
-
Save Fhernd/b8773498c009d56a18c53de9bb1106fa to your computer and use it in GitHub Desktop.
Lectura de un documento XML en Python. OrtizOL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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