Using BeautifulSoup to parse my XML
import BeautifulSoup
soup = BeautifulSoup.BeautifulStoneSoup( """<alan x="y" /><anne>hello</anne>""" ) # selfClosingTags=['alan'])
print soup.prettify()
This will output:
<alan x="y">
<anne>
hello
</anne>
</alan>
ie, the anne tag is a child of the alan tag.
If I pass selfClosingTags=['alan'] when I create the soup, I get:
<alan x="y" />
<anne>
hello
</anne>
Great!
My question: why can't the presence of the />
be used to indicate a self closing tag?