使用BeautifulSoup解析我的XMLselfClosingTags在BeautifulSoup
import BeautifulSoup
soup = BeautifulSoup.BeautifulStoneSoup("""<alan x="y" /><anne>hello</anne>""") # selfClosingTags=['alan'])
print soup.prettify()
這將輸出:
<alan x="y">
<anne>
hello
</anne>
</alan>
即安妮標籤是標籤艾倫的孩子。
如果我通過selfClosingTags = [ '阿倫']當我創建了湯,我得到:
<alan x="y" />
<anne>
hello
</anne>
太好了!
我的問題:爲什麼/>
的存在不能用於指示自動關閉標籤?