Search code examples
xmlpython-2.7plc

Parsing a Rockwell L5X file


I work in the machine automation industry and extensively uses PLC. I am thinking about a way to automate part of the logic creation which consists a lot of manual typing which I am trying to get rid off. Rockwell uses L5X files which is actually an XML file to do import export of program and tag databases. So my question here is Are l5X files same XML files or is there a difference? How can I parse it edit the data in that files? So I can batch edit the programs What will be the challenges in doing that considering I am a beginner in the coding world.


Solution

  • XML is an extendable markup language, which means that it allows for the definition of a markup vocabulary and grammar. Rockwell has defined the L5X format in XML. This allows tools and libraries that support XML to be used to read, manipulate, and write L5X files. This is a considerable advantage, providing you many options for processing L5X files: XPath, XSLT, XML parsers in many languages, including Python.

    Typically there would be an XML schema (XSD, DTD, Relax NG, Schematron, etc) file that defines the vocabulary and grammar and supports automated validation of the L5X file. Rockwell, unfortunately, appears to have forgone that convenience in their specification of the L5X format, but an XML schema could be written based upon their examples and natural-language-based specification.

    Clearly having programming skills would be a tremendous advantage here, but since XML is a text-based language, you could conceivably achieve some results in a text editor using manual editing, search-and-replace, and user-defined macros (in increasing order of sophistication).