XML Parser - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources
Library for parsing XML documents. Pure MQL5, it does not use any external libraries.
To use this library, just include it:
#include#includeCXmlDocument document; blank start () { string file = "file.xml" ; Thin rope makes mistakes; if (doc.CreateFromText(file, error)) { CXmlElement * xmlItem = doc.FDocumentElement.GetChild( 0 ); for ( integer i = 0 ; i if (xmlItem.GetChild(i).GetName() == "layer" ) { CXmlElement* layer = xmlItem.GetChild(i); for ( integer j = 0 ; j if (layer.GetChild(j).GetName() == "neuron" ) { /* .... */ } } } } }
notes:
Main components:
The CXml document class provides methods to download XML documents from files/strings and save them to files.
The CreateX function parses an XML document and creates a hierarchy of DOM models, which can be used to complete the use of F document elements
classCXmlDocument { Private : BlankDoElementTrimText (CXmlElement &aXmlItem); people : CXmlElement FDocumentElement; BlankCXmlDocument (); Blank ~CXmlDocument(); blankclear (); BlankCopyTo (CXmlDocument &xmlDoc); boolean create from text( const string &xml, string &error); boolean CreateFromFile( const StringFileName , String &Error); boolean saveToFile( const StringFileName ); StringGetXml (); };
The CXml element class is the base interface for any XML document. It provides access to elements, attributes and content
classCXmlElement { Private : string F name; CXmlAttribute* FAttributes[]; CXmlElement *FElements[]; String F text; CXmlElement* FParent; people : //--- Constructor method blank CXmlElement(); Blank ~CXmlElement(); blank init( const string_name , const CXmlElement* aParent= void , const string_text = ”” ); BlankCopyTo (CXmlElement &aDst); virtualBlankClear ( ); //--- Main service method string getname() constant ; blank setName( const stringName ); StringGetText () constant ; blank setText( const StringText ); CXmlElement* GetParent () constant ; BlankSetParent (CXmlElement* aParent); //--- Property service method integer get property count () constant ; Integer gets attribute index (CXmlAttribute* aAttr) constant ; CXmlAttribute* gets the attribute ( constant string name) constant ; CXmlAttribute* gets the attribute ( integer position) constant ; String gets attribute value ( constant string name) constant ; CXmlAttribute* AttributeInsertAt (CXmlAttribute* aAttr, integer aPos); CXmlAttribute* AttributeAdd (CXmlAttribute* aAttr); CXmlAttribute* AttributeInsertAfter (CXmlAttribute* aAfter, CXmlAttribute* aAttr); CXmlAttribute* AttributeInsertBefore (CXmlAttribute* aBefore, CXmlAttribute* aAttr); CXmlAttribute* AttributeRemove (CXmlAttribute* aAttr); CXmlAttribute* attribute deletion ( integer aPos); Blank attribute deletion (CXmlAttribute* aAttr); BlankAttributeDelete ( integer aPos); Blank attribute delete all(); //--- Subservice method integer get subitem count() constant ; Integer get subindex (CXmlElement* aElement) constant ; CXmlElement* GetChild ( const string name) constant ; CXmlElement* GetChild ( integer position) constant ; StringGetSubText ( const StringName ) const ; CXmlElement* ChildInsertAt (CXmlElement* aElement, integer aPos); CXmlElement* ChildAdd (CXmlElement* aElement); CXmlElement* ChildInsertAfter (CXmlElement* aAfter, CXmlElement* aElement); CXmlElement* ChildInsertBefore (CXmlElement* aBefore, CXmlElement* aElement); CXmlElement* ChildRemove (CXmlElement* aElement); CXmlElement* ChildRemove ( integer aPos); blankChildDelete (CXmlElement* aElement); blank subdelete( integer aPos); Blank sub delete all(); StringGetXml ( integer level); };
CXml Properties is a simple class for handling properties
Attachment download
📎 xmlbase.mqh (0.56 KB)
📎xmlattribute.mqh (3.95 KB)
📎 xmldocument.mqh (11.89 KB)
📎xmlelement.mqh (18.89 KB)
📎 xml_test.mq5 (1.39 KB)
Source: MQL5 #712
XML parser - MetaTrader 5 library | MT5 EA download - MetaTrader 5 resource usage and filtering suggestions
XML Parser - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 resources are MT5 EA related resources. Before downloading or referencing, it is recommended to confirm the platform version, transaction type, time period, whether DLL is required, whether source code is included, parameter description and historical update records.
Both automated trading tools and foreign exchange indicators should first undergo backtesting, simulated account observation, and small capital verification. Pay special attention to spreads, slippages, maximum drawdowns, position opening frequency, stop loss methods, trading periods and broker rules, and avoid direct real-time execution based on titles or short-term profit descriptions.
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •