This is a memo on how to set the xml:id attribute with BeautifulSoup.
The following method causes an error.
Writing it as follows works correctly.
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.