1
我正在編輯原始帖子在這裏澄清,並希望我已煮沸成更容易管理的東西。我有XML字符串,看起來像:BeautifulStoneSoup - 如何unescape和添加結束標記
<foo id="foo">
<row>
<img alt="jules.png" src="http://localhost/jules.png" height="1024" width="764">
</row>
<row>
<img alt="hairfire.png" src="http://localhost/hairfire.png" height="225" width="225">
</row>
</foo>
所以,我做這樣的事情:
xml = BeautifulStoneSoup(someXml, selfClosingTags=['img'], convertEntities=BeautifulSoup.HTML_ENTITIES)
的,其結果是一樣的東西:
<foo id="foo">
<row>
<img alt="jules.png" src="http://localhost/jules.png" height="1024" width="764">
</row>
<row>
<img alt="hairfire.png" src="http://localhost/hairfire.png" height="225" width="225">
</row>
</foo>
公告每個img標籤上都沒有結束標籤。不知道這是我的問題,但可能。當我嘗試做:
images = xml.findAll('img')
這是產生一個空的列表。任何想法爲什麼BeautifulStoneSoup在這個xml片段中找不到我的圖片?