This is a memo on how to set the xml:id attribute with BeautifulSoup.

The following method causes an error.

fssproorouuimppn.tb=a(sps4Bpoeeuianpmud)pt(oisrfotuulpBS.eonaueupwt(_iftfeauaglt(Su"orpue"ps,="axbmcl="")xyz",xml:id="abc"))

Writing it as follows works correctly.

fssproorouuimppn.tb=a(sps4Bpoeeuianpmud)pt(oisrfotuulpBS.eonaueupwt(_iftfeauaglt(Su"orpue"ps,="x*m{l""a)bc":"xyz","xml:id":"aiu"}))

An execution example on Google Colab is available below.

https://github.com/nakamura196/ndl_ocr/blob/main/BeautifulSoupでxml_id属性を与える方法.ipynb

We hope this is helpful.