Skip to main content

lvxml

Lianes8 Certified

Read and write LabVIEW's Flatten To XML data from Python, with no LabVIEW running. Typed, zero dependencies, Python 3.10 to 3.14.

The problem

LabVIEW's Flatten To XML and its file writer turn any LabVIEW value into one fixed XML shape: an element named after the data type (DBL, I32, Boolean, String, Cluster, Array, EW, ...) holding a <Name> and a <Val>, or for containers their sizes and children, usually inside an <LVData> file. A generic XML library parses the elements but knows none of the conventions, and LabVIEW's reader has its own rules: it decodes only three entities, writes control characters raw, puts a refnum's kind before its value and writes files in the system code page. lvxml follows what LabVIEW 2026 actually writes and reads, checked against files it wrote and values it read back.

Install

pip install lvxml

Quick start

>>> from lvxml import Array, Cluster, LVEnum, from_lv_xml, to_lv_xml
>>> from_lv_xml("<I32><Name>count</Name><Val>-7</Val></I32>")
-7
>>> from_lv_xml(
...     "<Cluster><Name>pt</Name><NumElts>2</NumElts>"
...     "<DBL><Name>x</Name><Val>1.5</Val></DBL>"
...     "<EW><Name>mode</Name><Choice>Idle</Choice><Choice>Run</Choice><Val>1</Val></EW>"
...     "</Cluster>"
... )
{'x': 1.5, 'mode': 'Run'}
>>> schema = Cluster({"x": "DBL", "mode": LVEnum(("Idle", "Run"))})
>>> print(to_lv_xml({"x": 1.5, "mode": "Run"}, schema, name="pt"))
<Cluster>
  <Name>pt</Name>
  <NumElts>2</NumElts>
  <DBL>
    <Name>x</Name>
    <Val>1.5</Val>
  </DBL>
  <EW>
    <Name>mode</Name>
    <Choice>Idle</Choice>
    <Choice>Run</Choice>
    <Val>1</Val>
  </EW>
</Cluster>

A file LabVIEW wrote is read as text in its code page and comes back byte for byte:

>>> from lvxml import dump, parse
>>> text = (
...     "<?xml version='1.0' standalone='yes' ?>\r\n<LVData xmlns=\"http://www.ni.com/LVData\">\r\n"
...     "<Version>26.3.1f1</Version>\r\n<Boolean>\r\n<Name>on</Name>\r\n<Val>1</Val>\r\n</Boolean>\r\n"
...     "</LVData>"
... )
>>> document = parse(text)
>>> document.version, document.values[0].val
('26.3.1f1', '1')
>>> dump(document) == text
True

The command line converts to and from JSON and validates files:

lvxml to-json --encoding cp1252 data.xml -o data.json
lvxml to-xml --encoding cp1252 data.json -o data.xml
lvxml validate data.xml

The guide covers every type, the typed tree, validation, errors, the command line and the evidence behind each rule. Changes are listed in the changelog.

Why

LabVIEW reads and writes this format natively, but only inside LabVIEW. On the Python side, the LabVIEW packages on PyPI work on other things: pylabview parses LabVIEW's binary file types, lvkit reads VIs and converts them to Python, and autolv drives a running LabVIEW. None of them turns this XML into Python values or writes XML that LabVIEW will read back, so that glue is usually written by hand around a generic XML parser, which gets entities, control characters and the code page wrong for real LabVIEW files. lvxml is that glue, small, typed and dependency free, tested against what LabVIEW 2026 itself writes and reads.

License

MIT. See the license.

Metadata

Release files for lvxml 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lvxml 1.0.0
File Size Uploaded
lvxml-1.0.0.tar.gz 75.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lvxml 1.0.0
File Interpreter ABI Platform
lvxml-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 109.9 kB

Release files / lvxml-1.0.0.tar.gz

Download URL lvxml-1.0.0.tar.gz
Size 75.9 kB
Tags Source
SHA-256 checksum
How to use checksums
32d8391d8f1dfaafd640fe6d412ab43ea96e12e1bf52e2f850e72a11bf94e5de
BLAKE2b-256 checksum
How to use checksums
78d148e822769e0d5e0ae8295850cf9d81e4586966ddc3fc245b057978ea630d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / lvxml-1.0.0-py3-none-any.whl

Download URL lvxml-1.0.0-py3-none-any.whl
Size 34.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
673c69f746a61d3f6f4e5027ee930ff44253a058f5ce0d7dc3e2492cfab836cb
BLAKE2b-256 checksum
How to use checksums
0b4a446d415ccef31b2473ee2c633b3dac8f4c8cf396f0e13e1c0b237a288c33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page