Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
how can I read a XML file and write the value in a codesys-variable?
Regards,
Malcolm
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-04-08
Originally created by: M.Schaber
Hi, Malcolm,
Could you be a little bit more specific what you want to do?
Regarding the "source":
Do you want to write the whole XML file into a String variable, or do you want to parse some specific value out of an XML file and write it to the codesys variable?
Regarding the "destination":
Do you want to write the value as initialization value in the declaration of the varible, or do you want to generate IEC code which writes that value at run-time, or do you want to write the value into a running application via CODESYS Monitoring, or do you want to write the value into a running application using OPC?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm interested too, I think malcom means to open an xml file and parse some tag with its relaed attribute/value and transfer both into codesys strings or value.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-07-04
Originally created by: M.Schaber
Hi, hki75,
For parsing the XML tags, you should be able to use any .NET XML parser, or with recent CODESYS versions, also the python standard library XML parser. (In older versions, you can manuall patch the missing files in the IronPython standard library directory.)
To write the value into IEC Source, curently, you only can use the PLCOpenXML format.
To write the value into a running CODESYS application, you can use the monitoring interface provided for python, or any OPC client library.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
how can I read a XML file and write the value in a codesys-variable?
Regards,
Malcolm
Originally created by: M.Schaber
Hi, Malcolm,
Could you be a little bit more specific what you want to do?
Regarding the "source":
Do you want to write the whole XML file into a String variable, or do you want to parse some specific value out of an XML file and write it to the codesys variable?
Regarding the "destination":
Do you want to write the value as initialization value in the declaration of the varible, or do you want to generate IEC code which writes that value at run-time, or do you want to write the value into a running application via CODESYS Monitoring, or do you want to write the value into a running application using OPC?
I'm interested too, I think malcom means to open an xml file and parse some tag with its relaed attribute/value and transfer both into codesys strings or value.
Originally created by: M.Schaber
Hi, hki75,
For parsing the XML tags, you should be able to use any .NET XML parser, or with recent CODESYS versions, also the python standard library XML parser. (In older versions, you can manuall patch the missing files in the IronPython standard library directory.)
To write the value into IEC Source, curently, you only can use the PLCOpenXML format.
To write the value into a running CODESYS application, you can use the monitoring interface provided for python, or any OPC client library.