ElementType (ENUM) ¶ TYPE ElementType : Type of the xml element InOut: Name Initial Comment Element 0 Marks an element CDATAElement 1 Marks an element with CDATA Attribute 2 Marks an attribute of an element Comment 3 Marks an comment NotSet 4 Marks an empty element
Encoding (ENUM) ¶ TYPE Encoding : Encoding of a xml file InOut: Name Initial Comment UTF8 0 UFT-8 encoding UTF16 1 UTF-16 encoding
READ_MODE (ENUM) ¶ TYPE READ_MODE : Read modes InOut: Name Initial Comment ONE_ELEMENT 0 Reads only the specified element CHILDREN_ONLY 1 Reads all child elements of the specified element RECURSIVE 2 Reads all underlying elements of the specified element
Function Blocks ¶ Function blocks to read, write and find XML elements. XMLFindElement (FunctionBlock) XMLFindElementAsync (FunctionBlock) XMLFindElementByStringAsync (FunctionBlock) XMLGetElement (FunctionBlock) XMLGetElementAsync (FunctionBlock) XMLWrite (FunctionBlock) XMLWriteAsync (FunctionBlock)
XMLFindElement (FB) ¶ FUNCTION_BLOCK XMLFindElement Finds a xml element by name and attribute. Use the function block XMLFindElementAsync for large XML files to find the value asynchronously. To read from file set sFileName to file path and paDataArray = 0. To read from data array set sFileName = ‘’ and paDataArray to data pointer. InOut: Scope Name Type Initial Comment Input sFileName STRING(255) Path to a xml file wsElement WSTRING(gc_udiMaxValueSize) The element to find. if blank, the root element will be returend. attribute XMLElement Attributes of the xml element to find. readMode READ_MODE Read mode paElements POINTER TO XMLElement Pointer to the result set udiMaxElements UDINT Maximum size of paElements udiStartPosition UDINT 0 Start position in bytes xTruncateValues BOOL FALSE true: All values that exceed the maximum value size will be truncated paDataArray POINTER TO BYTE 0 Pointer to XML data array, if 0 read from file (sFileName) udiDataArraySize UDINT 0 Size of paDataArray Output eError ERROR Error udiCountElements UDINT Number of elemnents in paElements udiNextReadPos UDINT Position in file (in bytes) of the next xml element, 0 if last element eEncoding Encoding Encoding of the xml file
XMLFindElementAsync (FB) ¶ FUNCTION_BLOCK XMLFindElementAsync EXTENDS CBM.ETrig Finds a xml element by name and attribute asynchronously, i.e. distributed on several cycles. This function block should be used to find elements in large xml files. To read from file set sFileName to file path and paDataArray = 0. To read from data array set sFileName = ‘’ and paDataArray to data pointer. InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input sFileName STRING(255) Path to a file wsElement WSTRING(gc_udiMaxValueSize) The element to find. if blank, the root element will be returend. attribute XMLElement Attributes of the xml element to find. readMode READ_MODE Read mode paElements POINTER TO XMLElement Pointer to the result set udiMaxElements UDINT Maximum size of paElements udiStartPosition UDINT 0 Start position in bytes xTruncateValues BOOL FALSE true: All values that exceed the maximum value size will be truncated paDataArray POINTER TO BYTE 0 Pointer to XML data array, if 0 read from file (sFileName) udiDataArraySize UDINT 0 Size of paDataArray Output eError ERROR Error code if xError is true eLastError ERROR The last error udiCountElements UDINT Number of elemnents in paElements udiNextReadPos UDINT Position in file (in bytes) of the next xml element, 0 if last element eEncoding Encoding Encoding of the xml file
XMLFindElementByStringAsync (FB) ¶ FUNCTION_BLOCK XMLFindElementByStringAsync EXTENDS CBM.ETrig {attribute ‘hide_all_locals’} InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input sFileName STRING(gc_udiMaxValueSize) Path to a file wsElement STRING(gc_udiMaxValueSize) The element to find. if blank, the root element will be returend. attributeName STRING(gc_udiMaxValueSize) Name of the attribute, BLANK if not required attributeValue STRING(gc_udiMaxValueSize) Value of the attribute readMode READ_MODE Read mode paElements POINTER TO XMLElement Pointer to the result set udiMaxElements UDINT Maximum size of paElements udiStartPosition UDINT 0 Start position in bytes xTruncateValues BOOL FALSE true: All values that exceed the maximum value size will be truncated paDataArray POINTER TO BYTE 0 Pointer to XML data array, if 0 read from file (sFileName) udiDataArraySize UDINT 0 Size of paDataArray Output eError ERROR Error code if xError is true eLastError ERROR The last error udiCountElements UDINT Number of elemnents in paElements udiNextReadPos UDINT Position in file (in bytes) of the next xml element, 0 if last element eEncoding Encoding Encoding of the xml file
XMLGetElement (FB) ¶ FUNCTION_BLOCK XMLGetElement Reads a xml element from file. Use the function block XMLGetElementAsync for large XML files to get the values asynchronously. To read from file set sFileName to file path and paDataArray = 0. To read from data array set sFileName = ‘’ and paDataArray to data pointer. InOut: Scope Name Type Initial Comment Input sFileName STRING(255) Path to a file udiStartPosition UDINT Start position in file to read elements. Use XMLElement.udiPosition´ readMode READ_MODE Read mode paElements POINTER TO XMLElement Pointer to the result set udiMaxElements UDINT Maximum size of paElements xTruncateValues BOOL FALSE true: All values that exceed the maximum value size will be truncated paDataArray POINTER TO BYTE 0 Pointer to XML data array, if 0 read from file (sFileName) udiDataArraySize UDINT 0 Size of paDataArray Output eError ERROR Error udiCountElements UDINT Number of elemnents in paElements# udiNextReadPos UDINT Position in file (in bytes) of the next xml element, 0 if last element eEncoding Encoding Encoding of the xml file
XMLGetElementAsync (FB) ¶ FUNCTION_BLOCK XMLGetElementAsync EXTENDS CBM.ETrig Reads a xml element from file asynchronously, i.e. distributed on several cycles. This function block should be used to get elements of large xml files. To read from file set sFileName to file path and paDataArray = 0. To read from data array set sFileName = ‘’ and paDataArray to data pointer. InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input sFileName STRING(255) Path to a file udiStartPosition UDINT Start position in file to read elements. Use XMLElement.udiPosition´ readMode READ_MODE Read mode paElements POINTER TO XMLElement Pointer to the result set udiMaxElements UDINT Maximum size of paElements xTruncateValues BOOL FALSE true: All values that exceed the maximum value size will be truncated paDataArray POINTER TO BYTE 0 Pointer to XML data array, if 0 read from file (sFileName) udiDataArraySize UDINT 0 Size of paDataArray Output eError ERROR Error code if xError is true eLastError ERROR The last error udiCountElements UDINT Number of elemnents in paElements# udiNextReadPos UDINT Position in file (in bytes) of the next xml element, 0 if last element eEncoding Encoding Encoding of the xml file
XMLWrite (FB) ¶ FUNCTION_BLOCK XMLWrite Writes a xml file. Use the function block XMLWriteAsync for large XML files to write the values asynchronously. To write to file set sFileName to file path and paDataArray = 0. To write to data array set sFileName = ‘’ and paDataArray to data pointer. InOut: Scope Name Type Initial Comment Input sFileName STRING(255) Path to a file paElements POINTER TO XMLElement Pointer to the result set udiCountElements UDINT Number elements in paElements eEncoding Encoding File encoding paDataArray POINTER TO BYTE 0 Pointer to XML data array, if 0 write to file (sFileName) udiDataArraySize UDINT 0 Size of paDataArray xAddDeclaration BOOL TRUE Adds XML declaration with encoding info like ‘<?xml version=”1.0” encoding=..’, default: TRUE Output eError ERROR Error