0

I want to parse an xml, but I can't find any good tutorials.

    import urllib.request
    import xml.etree.ElementTree as ET

    with urllib.request.urlopen('http://www.nbp.pl/kursy/xml/lastA.xml') as response:
    lasta = response.read()

What exactly is lasta. Is it still xml or a string or something else?

Richard Erickson
  • 2,568
  • 8
  • 26
  • 39
Krzyden
  • 1
  • 2
  • Indentation will be a problem for the last line. That matters for Python. It'll be a string that you need to parse into a DOM tree. – duffymo Feb 29 '16 at 18:48

1 Answers1

0

I would suggest BeautifulSoup: Python BeautifulSoup XML Parsing It has a bunch of helper methods that makes navigating a tree-structure (XML, or HTML) easier.

As to your question, 'lasta' is just a string, it hasn't been converted to XML yet. For downloading files over the internet, you may want to consider using the requests package as that is recommended for high-level HTTP operations.

Community
  • 1
  • 1
AnilRedshift
  • 7,937
  • 7
  • 35
  • 59