how can I read a XML file and write the value in a codesys-variable?
Originally created by: M.Schaber
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.
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.
Log in to post a comment.