IMDHMIControls LibraryShop main store

Troubleshooting

Import PLC Coder XML into TwinCAT 3 with PLCopen import

PLC programming Published 5 min read

Short answer

The "cannot consume the specified XML" error in TwinCAT 3 means the file reached a generic project-tree XML import, not the PLCopen importer. Right-click the PLC project in the solution tree, choose Import PLCopenXML and select the generated file. The command and its destination decide success; the XML stays as generated.

On this page
  1. Why the wrong import rejects a good file
  2. The import route that works
  3. Confirm the producer before the next attempt
  4. What the PLCopen standard does here
  5. Build and prove the imported objects
  6. The decision for each case
  7. Questions asked

TwinCAT 3 throws "cannot consume the specified XML. The XML content has no meaning for the tree item" when the generated file goes through a generic project-tree XML import instead of the PLCopen importer. The file is fine; the route is wrong. Right-click the PLC project in the Visual Studio solution tree, choose Import PLCopenXML, and select the generated file in the dialog. The command and its destination decide the outcome — nothing on the controller, the network, or in the XML itself needs to change.

Why the wrong import rejects a good file #

An .xml extension only says the document is well-formed XML. Every import command in the solution tree expects one document structure and writes into one kind of destination. The generic XML import you reached for handles other project-tree content; pointed at a PLCopen document, it has no mapping for what the file describes, so it reports that the content has no meaning for the tree item you selected. The message names the mismatch between importer and destination, not a defect in the generated code.

The operation is also entirely local: the file travels from the generation output folder into the TwinCAT PLC project on your engineering PC. No request goes to the controller, so its address and runtime state are not part of this failure — leave them alone until the import succeeds.

The import route that works #

  1. Open the TwinCAT solution in Visual Studio 2015, with the TwinCAT 3 add-in you already have installed.
  2. In the solution tree, find the PLC project that will receive the generated code — the PLC project node itself, not the solution root or a configuration item above it.
  3. Right-click that PLC project, or a folder inside it if the objects should land in that folder. The destination you mark is where the imported objects appear.
  4. Choose Import PLCopenXML from the context menu.
  5. Select plcdemo_external_symbols.xml in the file dialog. The dialog lists all objects the PLCopen file contains that TwinCAT can import; tick the ones you want.
  6. Read the import messages, then check the project tree for the new objects.

If Import PLCopenXML is missing from the menu, the selection is wrong: the solution root and configuration items do not offer it, and a solution with no PLC project has no node that does. Click the PLC project itself, or add one first.

Confirm the producer before the next attempt #

With the route fixed, prove the file is fresh output shaped for this target. The example setup, using the shipped example model:

Item Value What it proves
Model plcdemo_external_symbols A defined test case, identical on every run
Configuration area PLC Code Generation Where the target selection lives
Target IDE Beckhoff TwinCAT 3 Output written for the TwinCAT importer
Generation command PLC Code > Generate Code for Subsystem Produces the file from the subsystem
Output file plcdemo_external_symbols.xml The file the import consumes
  • Compare the file's modification time with your last generation run. An older file means you are importing stale output from a previous attempt.
  • If Target IDE shows anything other than Beckhoff TwinCAT 3, correct it and regenerate. Do not rename the extension or hand-edit the XML to please the wrong importer — that adds a second fault on top of the routing one.

What the PLCopen standard does here #

The file follows the PLCopen specification "XML formats for IEC 61131-3", currently at version 2.01. The standard fixes how IEC 61131-3 objects — programs, function blocks, data types — are serialized, so any conforming tool can exchange them; the importing tool filters which parts it can use, which is why TwinCAT shows a selectable list instead of loading everything blindly. Export PLCopenXML is the same channel in reverse: it writes project objects out to an XML file in PLCopen format, which is what makes the round-trip proof described in the FAQ possible.

Because the format is vendor-neutral, the generated file is not tied to one engineering environment — other tools with a PLCopen importer accept it too, as when you are importing PLCopen XML logic into OpenPLC v4.

Build and prove the imported objects #

Import success proves the file handoff, nothing more. The importer creates project objects; the compiler is what checks their declarations and references inside your application.

  • Build the PLC project and read the diagnostics. Unresolved symbols or conflicting declarations belong to integration — the generated code expects supporting declarations in the receiving project — not to the import.
  • Fix each diagnostic in the generated-code integration or the project declarations, then rebuild. The pass result for the whole procedure is: objects visible in the tree and a build completing with 0 errors.
  • Wire the imported blocks in like any other call; the input and output wiring is the same one you use to connect a TON output to a function block input in TwinCAT ladder.

Do this in a test copy of the project first. If you want that test project to execute alongside the existing application on the same engineering machine, that is the setup you use to run two TwinCAT PLC programs on one laptop. Do not download to a production controller until the test build is clean and the generated logic has been exercised against the real I/O.

The decision for each case #

  • The error appears at a solution or configuration node: wrong importer. Re-run the import from the PLC project's context menu with Import PLCopenXML; the file stays exactly as generated.
  • Import PLCopenXML is absent everywhere: no PLC project is selected, or none exists. Select the PLC project, or add one to the solution.
  • The correct command still rejects the file: verify Target IDE reads Beckhoff TwinCAT 3, regenerate, confirm the timestamp, and retry. If it fails at the correct node, the fault is in the document's content — a generation problem, not a routing one.
  • Import succeeds and the build fails: integration stage. Resolve declarations and references in the receiving project; the import route is no longer the issue.
  • Import succeeds and the build is clean: the procedure passed. Download only from the tested project.

Questions asked

Do I need the controller connected to import the XML file?

No. Import PLCopenXML is a file operation inside Visual Studio on the engineering PC: the generated file is parsed and turned into PLC project objects without any traffic to the controller. The PLC, its address and the runtime first become involved later, when you build, log in and download the tested project.

How can I prove the import command works before blaming the generated file?

Round-trip a known-good object. In the receiving PLC project, right-click an existing object and use Export PLCopenXML to write it to a file, then import that file back at the same node with Import PLCopenXML. If the round-trip succeeds while the generated file fails at the same node, the import route is proven and the fault is in the generated document's content, which points back to generation settings.

What if Import PLCopenXML is missing from every context menu?

The command is offered on a PLC project or a folder inside one, so a solution that contains no PLC project has no node that shows it. Add a PLC project to the TwinCAT solution first, then right-click it. Selecting the solution root or a configuration item never brings the command up, however the file is named or where it is stored.

Does a successful import change the running machine?

No. The import only creates objects in the engineering project on your PC; nothing is written to the controller and the running program stays untouched until you deliberately download. When you do download, use the project that built with 0 errors after the import, not an earlier attempt that still carried unresolved references.

Keep reading

  • How-to

    How to OR a comparator with a contact in Machine Expert HVAC ladder

    Machine Expert - HVAC will not build a GT comparator block inside a ladder parallel branch. Get the same Boolean OR by splitting the logic across two networks or by replacing the block with an expression combined through an OR block, then verify all four input combinations before download.

    PLC programming

  • How-to

    Connect a TON output to a function block input in TwinCAT ladder

    In TwinCAT ladder, the rung's power flow always lands on a block's first input, so with NT_GetTime it lands on NETID instead of START. Right-click the rung and choose Box with EN to create an enable path, then right-click the short line before START and use Insert at Block... to place a box there, replacing the default AND with TON by typing the name or using Input Assistant with F2.

    PLC programming

  • How-to

    How to verify AI-generated PLC code before you trust it

    A clean compile proves your AI-generated rung is syntactically valid for the project, not that it behaves correctly. Write a behavior specification first — states, startup, fault response, reset — then run normal, abnormal and restart tests in an isolated environment before any download to operating equipment. Generated logic earns trust the same way hand-written logic does: by passing a test written before the code was accepted.

    PLC programming