0

I want to use Python to get open API data. So, I parsed the URL to XML and tried to get the information I wanted through findall().

part of the data,

<safemap:CTPRVN_CD>11</safemap:CTPRVN_CD>
<safemap:SGG_CD>11500</safemap:SGG_CD>

i want this,

root.findall('safemap:ctprvn_cd')

but returned empty list.

Indent
  • 4,675
  • 1
  • 19
  • 35
gwak
  • 9
  • 1

1 Answers1

1

XML is case-sensitive. I believe that root.findall('safemap:CTPRVN_CD') might work better.

Also I noticed that your xml seems to use namespaces. Usually there is a problem with namespaces, when working with xmls using lxml or xml package in python.

running.t
  • 5,329
  • 3
  • 32
  • 50
  • Start with getting rid of namespaces in your xml and using `findall` only wth `CTPRVN_CD` . If that helps read something about [working with namespaces in lxml](https://stackoverflow.com/questions/8053568/how-do-i-use-empty-namespaces-in-an-lxml-xpath-query) – running.t Jun 26 '18 at 13:00