15. XML in the OpenSCADA system (XMLNode)
XML in the OpenSACDA system is represented by the object of the XML-tag — XMLNode.
15.1. XML-tag (XMLNode)
Data:
Options for XML-file loading (enum — XMLNode::LoadFlgs):
- XMLNode::LD_Full — load XML full;
- XMLNode::LD_NoTxtSpcRemEnBeg — no remove spaces for begin and end tag's text, for not full mode.
Options of the function of XML-file generation (enum - XMLNode::SaveView):
- XMLNode::BrOpenPrev — insert the end of the line before the opening tag;
- XMLNode::BrOpenPast — insert the end of the line after the opening tag;
- XMLNode::BrClosePast — insert the end of the line after the closing tag;
- XMLNode::BrTextPast — insert the end of the line after the tag text;
- XMLNode::BrSpecBlkPast — insert the end of the line after the computed instruction;
- XMLNode::BrAllPast — insert the end of the line after the all elements;
- XMLNode::XMLHeader — insert the standard xml-header;
- XMLNode::Clean — result clean from comments and procedure insertions;
- XMLNode::XHTMLHeader — insert the standard XHTML-header;
- XMLNode::MissTagEnc — to miss for tags name encoding.
- XMLNode::MissAttrEnc — to miss for attributes name encoding.
Public methods:
- XMLNode( const string &name = "" ); — Initialization of the tag with the name.
- XMLNode( const XMLNode &nd ); — Copy constructor.
- XMLNode &operator=( const XMLNode &prm ); — Copying a branch of the XML-tree from prm.
- string name( ) const; — Tag's name.
- XMLNode* setName( const string &s ); — Setting the tag's name to s.
- string text( bool childs = false, bool recursive = false ) const; — Tag's text. childs — for text getting from special text nodes.
- XMLNode* setText( const string &s, bool childs = false ); — Setting the tag's text to s. childs — for set text to special text node.
- void attrList( vector<string> & list ) const; — List of attributes in the tag.
- XMLNode* attrDel( const string &name ); — Deleting of the attribute name.
- void attrClear( ); — Clean up the tag's attributes.
- string attr( const string &name, bool caseSens = true ) const; — Getting the attribute name.
- XMLNode* setAttr( const string &name, const string &val ); — Setting/creation of the attribute name with the value val.
- void load( const string &vl, unsigned flg = 0, const string &cp = "UTF-8" ); — Load/parsing of the XML-file, with source encoding cp and flags flg.
- string save( unsigned flg = 0, const string &cp = "UTF-8" ) const; — Saving/creation of the XML-file with the formatting parameter flg and encoding to cp.
- XMLNode* clear( ); — Clear the tag (recursively, including all childs).
- bool childEmpty( ) const; — Check for empty included tags.
- unsigned childSize( ) const; — Number of included tags.
- void childAdd( XMLNode *nd ); XMLNode* childAdd( const string &name = "" ); — Adding the included tag.
- int childIns( int id, XMLNode *nd ); — Insert of the included tag nd to the position id. Negative id counts from end.
- XMLNode* childIns( int id, const string &name = "" ); — Insert of the included tag with the name name to the position id. Negative id counts from end.
- void childDel( const int id ); — Deleting of the included tag id. Negative id counts from end.
- void childDel( XMLNode *nd ); — Deleting of the included tag using its address nd.
- void childClear( const string &name = "" ); — Clean up of the included tag name.
- XMLNode* childGet( const int, bool noex = false ) const; — Getting the included tag by its index number.
- XMLNode* childGet( const string &name, const int numb = 0, bool noex = false ) const; — Getting of the included numb indexed tag by the tag's name name. noex indicates the prohibition of the generation of exception in the case of absence of the tag.
- XMLNode* childGet( const string &attr, const string &vl, bool noex = false ) const; — Getting the included numb indexed tag by its value vl of the attribute attr. noex indicates the prohibition of the generation of exception in the case of absence of the tag.
- XMLNode* getElementBy( const string &attr, const string &val ); — Included node search by the value val of the attribute attr.
- void getElementsBy( const string &tag, const string &attr, const string &val, TArrayObj *rez ); — get elements array rez from the tree by tag (empty for all) and attribute attr value val (empty for pass).
- XMLNode* parent( ); — Parent tag of the tag.
- XMLNode* root( ); — Root tag of the tag.