I'm writing a python script that uses beautiful soup to parse xml documents. Some of the documents contain elements named "area". For some reason I cannot for the life of me properly parse these elements. They always come out as empty <area/> elements.
Here is a minimal example of what is happening:
#!/usr/bin/python3.5
from bs4 import BeautifulSoup
xml = """""
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?>
<root>
<areax>
foo
</areax>
<area>
bar
</area>
</root>
"""""
soup = BeautifulSoup (xml, "lxml")
print ("\n#### soup ####\n")
print (soup)
print ("\n#### areax ####\n")
areaxs = soup.find_all ("areax")
for areax in areaxs:
print (areax)
print ("\n### area ###\n")
areas = soup.find_all ("area")
for area in areas:
print (area)
Output:
#### soup ####
<html><body><p>""
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?>
<root>
<areax>
foo
</areax>
<area/>
bar
</root>
</p></body></html>
#### areax ####
<areax>
foo
</areax>
### area ###
<area/>
Is the element name "area" protected in any way or is there something else wrong with how I'm parsing it?