This is a memo on how to get an element with a specific xml:id value using JavaScript’s querySelector().

Specifically, for a variable called myDoc, you can retrieve the element as follows. This example gets the element with the value abc in its xml:id attribute.

myDoc.querySelector("[*|id=‘abc’]")

The key point is to specify it in the format *|(pipe)id.

When working with TEI/XML files in JavaScript, there are cases where you need to retrieve elements using xml:id attribute values. Unlike other attributes such as type or corresp, the xml:id attribute has the prefix “xml:” in its attribute name. Therefore, you need to use the approach described above.

There may be better or alternative methods, but we hope this serves as a useful reference.