<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/</id><updated>2024-06-28T21:59:30.939000Z</updated><subtitle>Recent posts to Import XML</subtitle><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#ff9b" rel="alternate"/><published>2024-06-28T21:59:30.939000Z</published><updated>2024-06-28T21:59:30.939000Z</updated><author><name>codesysdave</name><uri>https://forge.codesys.com/u/codesysdave/</uri></author><id>https://forge.codesys.comb37644da1ee5eecacf38d321bcf39e5f99cfea8b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Great info from 2011... thanks!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#eedb" rel="alternate"/><published>2020-02-27T14:57:00.347000Z</published><updated>2020-02-27T14:57:00.347000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comf0fb5c7a2ca2fe7d26f2c600c390ad28f6998126</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Lohr_DCIA-EHE1 hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
The import of the commentaries of the properties via the menu function does not work either.&lt;br/&gt;
All commentaries above FUNCTION_BLOCK MX_DirectVarAxis are lost, too !!&lt;br/&gt;
// {attribute 'signature_flag' := '12345'}        &amp;lt;-- lost&lt;br/&gt;
//{attribute 'hide'}//hide POU                      &amp;lt;-- lost&lt;br/&gt;
{attribute 'signature_flag' := '1275068416'}   &amp;lt;-- lost &lt;br/&gt;
FUNCTION_BLOCK MX_DirectVarAxis             &amp;lt;-- from here on everything is copied.&lt;br/&gt;
VAR&lt;br/&gt;
  //{attribute 'hide'}//hide POU&lt;br/&gt;
  {attribute 'noinit'}&lt;br/&gt;
    usCmdAchse : UINT;  // Achse fuer den Parameter-Zugriff&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Then it's a general PLCOpenXML problem, and not specific to scripting. So I'm afraid I'm not in charge of it.   &lt;/p&gt;
&lt;p&gt;I think the best is that you file a bug report via our support department. Especially mention that the {attribute}s are lost, as that information is more important than "noarmal" comments.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#0319" rel="alternate"/><published>2020-02-27T14:56:59.779000Z</published><updated>2020-02-27T14:56:59.779000Z</updated><author><name>Lohr-DCIA-EHE1</name><uri>https://forge.codesys.com/u/lohr-dcia-ehe1/</uri></author><id>https://forge.codesys.comb5b0e00818ba67ee0f68193d6af8d0d582a37f54</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The import of the commentaries of the properties via the menu function does not work either.&lt;/p&gt;
&lt;p&gt;All commentaries above FUNCTION_BLOCK MX_DirectVarAxis are lost, too !!&lt;/p&gt;
&lt;p&gt;// {attribute 'signature_flag' := '12345'}        &amp;lt;-- lost&lt;br/&gt;
//{attribute 'hide'}//hide POU                      &amp;lt;-- lost&lt;br/&gt;
{attribute 'signature_flag' := '1275068416'}   &amp;lt;-- lost &lt;br/&gt;
FUNCTION_BLOCK MX_DirectVarAxis             &amp;lt;-- from here on everything is copied.&lt;br/&gt;
VAR&lt;br/&gt;
  //{attribute 'hide'}//hide POU&lt;br/&gt;
  {attribute 'noinit'}&lt;br/&gt;
    usCmdAchse : UINT;  // Achse fuer den Parameter-Zugriff&lt;br/&gt;
END_VAR&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#17b0" rel="alternate"/><published>2020-02-27T14:56:58.106000Z</published><updated>2020-02-27T14:56:58.106000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comfeb8950feea7c543234d2af2fc754cba2794b26f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi, Lohr_DCIA-EHE1,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Lohr_DCIA-EHE1 hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
I had exported some properties of a function block as XML-file using the menu function "Export PLCopen XML" and then wanted to import that with the function import_xml(). That worked fine, but all commentaries of the properties were not imported.&lt;br/&gt;
Example:&lt;br/&gt;
// P-0-0011 -READ- Last valid position command value   &amp;lt;-- This was not imported !!!&lt;br/&gt;
PROPERTY P_0_0011 : DINT                                      &amp;lt;--  This was imported !!!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Can check whether the comments are correctly imported when you do the import via the menu function?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#af24" rel="alternate"/><published>2020-02-27T14:56:57.513000Z</published><updated>2020-02-27T14:56:57.513000Z</updated><author><name>Lohr-DCIA-EHE1</name><uri>https://forge.codesys.com/u/lohr-dcia-ehe1/</uri></author><id>https://forge.codesys.com13099532bea60f3e375ff72678d4c97367edf03f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I had exported some properties of a function block as XML-file using the menu function "Export PLCopen XML" and then wanted to import that with the function import_xml(). That worked fine, but all commentaries of the properties were not imported.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;// P-0-0011 -READ- Last valid position command value   &amp;lt;-- This was not imported !!!&lt;br/&gt;
PROPERTY P_0_0011 : DINT                                      &amp;lt;--  This was imported !!!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#d0d0" rel="alternate"/><published>2020-02-27T14:56:56.904000Z</published><updated>2020-02-27T14:56:56.904000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com03f02c2609f33818f7019e4891ec2ee3319fa059</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The import and export process gives notifications about errors, warnings and progress. The purpose of the reporter is to process those notifications during the export or import process.&lt;/p&gt;
&lt;p&gt;For native export, passing the reporters is optional. For PLCOpenXML, we're working on making them optional.&lt;/p&gt;
&lt;p&gt;HTH,&lt;br/&gt;
Markus&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#069b" rel="alternate"/><published>2020-02-27T14:56:55.186000Z</published><updated>2020-02-27T14:56:55.186000Z</updated><author><name>timvh</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.comf9b68a2a5f72f2ef6002a0121cc625f386ed82cd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can see that the import function uses the reporter class, therefore I added it.&lt;br/&gt;
The example is based on an example in the help and some addional help from 3S-Software.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#58c2" rel="alternate"/><published>2020-02-27T14:56:54.474000Z</published><updated>2020-02-27T14:56:54.474000Z</updated><author><name>aoj</name><uri>https://forge.codesys.com/u/aoj/</uri></author><id>https://forge.codesys.com31601024718c296f85f4f785d9503d7eae034d5b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi TimvH,&lt;/p&gt;
&lt;p&gt;I wrote a script, which imports a XML to CoDeSys. Than I saw here in the forum, that you had created a script for importing XML. You defined in your script a class "Reporter". Could you please explain the function of this class. Is it important to have this class in the script?&lt;/p&gt;
&lt;p&gt;Thanks a lot.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Import XML</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f169c9777c/?limit=25#1d41" rel="alternate"/><published>2020-02-27T14:56:52.736000Z</published><updated>2020-02-27T14:56:52.736000Z</updated><author><name>timvh</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.comb22b12896cdc961329648805a17138edc6fe137d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I wanted to create a script which could import an XML file.&lt;br/&gt;
I first exported a GVL and wanted to import it, but I noticed it was placed in the POU pool.&lt;br/&gt;
With this example it places it "under" the application of the Device.&lt;/p&gt;
&lt;p&gt;Create the .xml file, open a project with a device (PLC) and application and run the script.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;\&lt;span class="c1"&gt;# script example importXML.py&lt;/span&gt;
\&lt;span class="c1"&gt;# current project&lt;/span&gt;
&lt;span class="n"&gt;proj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;projects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primary&lt;/span&gt;
\&lt;span class="c1"&gt;# create the import reporter&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Reporter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ImportReporter&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Severity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;warning&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Severity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Warning&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;resolve_conflict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ConflictResolve&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Copy&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;added&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"added: "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;replaced&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"replaced: "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;skipped&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"skipped: "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nd"&gt;@property&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;aborting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
\&lt;span class="c1"&gt;# create the importer instance.&lt;/span&gt;
&lt;span class="n"&gt;reporter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Reporter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; 
\&lt;span class="c1"&gt;# import xml&lt;/span&gt;
&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;proj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Application"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"number of item Application: {0}"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;import_xml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reporter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"C:\_d\Python\importXML\myXML.xml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"add item"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry></feed>