python lxml xpath multiple namespace matching but not all
02:55 20 Apr 2026

How can I get lxml xpath to match two namespaces like cims and cims51 but not all:

    'cimc': "urn:iec62325.351:tc57wg16:451-3:capacitydocument:8:0",
    'cimc71': "urn:iec62325.351:tc57wg16:451-3:capacitydocument:7:1",
    'cims': "urn:iec62325.351:tc57wg16:451-2:scheduledocument:5:0",
    'cims51': "urn:iec62325.351:tc57wg16:451-2:scheduledocument:5:1",
:
mrids = xml.xpath(tag, namespaces=NAMESPACES)
:
TypeError: failed extracting xpath tag='//cims51:mRID' from xml

The tag was //cims:mRID how can I combine it so it matches both cims and cims51.

I know I can use tag like :

mrids = xml.xpath(r"//*[local-name()='mRID']")

But I then I get msirds from all the timeseries in the message.

I can do:

mrids = xml.xpath('//cims:mRID | //cims51:mRID', namespaces=NAMESPACES)

But there are lots of older cmic versions.

Is there a way to do:

mrids = xml.xpath('//cims*:mRID', namespaces=NAMESPACES)
python lxml