Home

aliazzz

codesuccessful Computer says no!

Project Members:

Download

Download XmlPac.library

Usage

Simple and straightforward XML parsing and composing library.

Composing Usage example:

  1. Initialise
VAR
    XML : FB_XMLControl;
    Buffer: STRING(GVL_Param_XmlControl.udiMaxFileSize);
    // or 
    Buffer: ARRAY [0..GVL_Param_XmlControl.udiMaxFileSize] OF BYTE;
END_VAR
XML.pBuffer: = ADR (buffer);
XML.LenBuffer: = SIZEOF (buffer);

Add your own preferred fileheader like:

<?xml version="1.0" encoding="UTF-8"?>

XML.WriteDocumentHeader( '<?xml version="1.0" encoding="UTF-8"?>');
  1. Compose a tag with a parameters:
    <MyTag ParaName = "11" />
    
XML.newTag(sTagName: = 'MyTag');
XML.newParameter(Name: = 'ParaName', Parameter: = 11);
XML.CloseTag();
  1. Add tag value:
    <MyTag> MyText </ MyTag>
    
XML.newTag(Name := 'MyTag');
XML.newTagData(TagData :='MyText');
XML.CloseTag();
  1. Jump to the beginning of the XML data
XML.toStartBuffer();
  1. Add a comment;
XML.newComment(sTagName: = 'MyComment');
  1. Returns the next tag from the current position in buffe;
XML.NextTag();
  1. Output the parameter of the tag;
XML.NextParameter(Parameter: = LastValue);

Feedback: Parameter returns the value found (string)

Contents of the library

FB_FileControl;
This function block can open, close, read and save from and to a generic plc memory buffer

Note: Files do not neccesarily need to be in a .xml format ;-)

FB_StringBuffer;
This functionblock acts as an IO stream buffer for use with FB_XmlControl

FB_XmlControl:
Organizes parsing and composing of XML data. Data can be treated as STRING or char array.
Filebuffersize can be set via library parameter (Gvl_Param_XmlControl)

Download XmlPac.library


Start a new Talk topic