Skip to content

MTConnect Python library cannot parse real Haas probe.xml device files #1

Description

@zachfrey

Problem

The mtconnect Python library (PyPI package) cannot parse device XML files fetched directly from real Haas CNC machines via the /probe endpoint. This prevents using authentic machine configurations.

Error

ValueError: Missing required id for MTC

Root Cause

xmlhelper.py has two limitations:

  1. No XML namespace support

Real Haas probe responses use MTConnect 1.2 namespaces:

<MTConnectDevices xmlns="urn:mtconnect.org:MTConnectDevices:1.2" ...>

The library uses simple element.find("Device") calls. With namespaces, tags become {urn:mtconnect.org:MTConnectDevices:1.2}Device, so find("Device") returns None.

  1. Assumes Device elements are direct children of root

Real probe responses have a

and wrapper:

<MTConnectDevices>
    <Header .../>
    <Devices>
        <Device id="dev1" ...>

The library iterates list(root), expecting Device elements. Instead it gets Header (no id attribute) and Devices (wrapper, also no id), triggering the error.

Workaround

Use a manually created XML without namespaces and without the wrapper.

Proposed Fix

Patch xmlhelper.py to:

Strip XML namespaces from element tags
Skip <Header> elements
Unwrap <Devices> container to find actual Device elements

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions