【发布时间】:2019-10-18 17:41:29
【问题描述】:
如何使用beautifulsoup 选择和修改标签<Tagwith.dot> 以及其他一些文本?如果使用 beautifulsoup 无法实现,那么下一个用于 xml 文档编辑和创建的最佳库是 lxml?
from bs4 import BeautifulSoup as bs
stra = """
<body>
<Tagwith.dot>Text inside tag with dot</Tagwith.dot>
</body>"""
soup = bs(stra)
所需的 XML:
<body>
<Tagwith.dot>Edited text</Tagwith.dot>
</body>
【问题讨论】:
标签: python xml python-3.x beautifulsoup lxml