Fhernd icon

manipular-xml.py

Fhernd | PRO | 07/24/18 02:32:21 PM UTC | 0 ⭐ | 3011 👁️ | Never ⏰ | []
Python |

440 B

|

None

|

0 👍

/

0 👎

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'))

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎