FB_XmlSrvReadByName

FB_XmlSrvReadByName 1:

The function block FB_XmlSrvReadByName can be used to initialize a PLC variable with data from an XML file. The input variable sXPath must point to a valid node in the XML file specified via sFilePath. The symbol to be initialized is identified unambiguously by the symbol name.

VAR_INPUT

VAR_INPUT
    sNetId      : T_AmsNetId; 
    ePath       : E_OpenPath := PATH_GENERIC; 
    nMode       : WORD := XMLSRV_SKIPMISSING;
    sSymName    : T_MaxString;
    sFilePath   : T_MaxString;
    sXPath      : T_MaxString;
    bExecute    : BOOL; 
    tTimeout    : TIME := T#60s; 
END_VAR

sNetId: String containing the network address of the TwinCAT XML Data Server. For the local computer (default) an empty string may be specified.

ePath: This input can be used to select a TwinCAT system path on the target device for opening the file.

nMode: This input can be used to influence how the XML file is analyzed. For the XmlSrvReadByName command, only XMLSRV_SKIPMISSING mode is currently supported.

sSymName: Name of the PLC symbol to which the data from the XML file are to be written.

sFilePath: Contains the path and file name for the file to be opened. Note: The path can only point to the local computer’s file system! This means that network paths cannot be used here!

sXPath: Contains the address of the tag in the XML document from which the data are to be written. The address must be a valid XPath instruction. The name of the tag must be different from the name of the symbol.

bExecute: The block is activated by a rising edge at this input.

tTimeout: Maximum time allowed for the execution of the function block.

VAR_OUTPUT

VAR_OUTPUT
    bBusy   : BOOL;
    bError  : BOOL;
    nErrId  : UDINT;
END_VAR

bBusy: This output is set when the function block is activated. It remains set until feedback is received.

bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.

nErrId : If the bError output is set, this parameter returns the TwinCAT XML Data Server error number.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v2.10.0

PC or CX (x86, ARM)

TcXmlDataSrv.Lib

( Standard.Lib; TcBase.Lib; TcSystem.Lib are included automatically )