Easy XML Parser for MT5
Info
The Easy XML Parser for MT5 is a Library for MetaTrader 5 that easyxml: a powerful xml and xhtml parser for mql5core functionality and capabilitieseasyxml is a robust yet user-friendly xml parser designed to read and process xml data from multiple sources, including urls, file inputs, and string inputs. It is entirely developed in native MQL5 and utilizes the Windows native 'wininet.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Library works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Libraries folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Easy XML Parser for MT5
1. Storage: Place library files in the MQL/Libraries directory to ensure they are accessible to your projects.
2. Implementation: Include the library in your code using the #import directive, ensuring you match the exact function names and parameters.
3. Compilation: Ensure the library is present in the directory before you compile your main EA or script, as the compiler links them during this phase.
4. Management: Keep libraries organized in sub-folders if you manage many custom functions to maintain a clean project structure.
Frequently Asked Questions
Q: What is a library file used for? A: Libraries store reusable code modules, allowing you to centralize common logic used by multiple EAs or indicators.
Q: Is a library executable? A: No, libraries are non-executable files containing functions; they must be imported into an EA, indicator, or script to function.
Q: Can I update a library while the platform is running? A: You should compile your EA or script after updating a library to ensure the latest code changes are integrated.
What this tool does
EasyXML: A Powerful XML and XHTML Parser for MQL5Core Functionality and CapabilitiesEasyXML is a robust yet user-friendly XML parser designed to read and process XML data from multiple sources, including URLs, file inputs, and string inputs.
Typical Use Case
This Library excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Library works on MetaTrader 5. Place the file in the MQL5/Libraries folder and restart the terminal.
Description & Settings
Related: xml parser for metatrader 4/5 - another powerful library for MetaTrader 5 traders.
EasyXML: A Powerful XML and XHTML Parser for MQL5Core Functionality and Capabilities
Also recommended: XML Parser for MetaTrader 5 - similar library with strong performance on MetaTrader 5.
EasyXML is a robust yet user-friendly XML parser designed to read and process XML data from multiple sources, including URLs, file inputs, and string inputs.It is entirely developed in native MQL5 and utilizes the Windows native 'wininet.dll' solely for retrieving XML documents from URLs.
EasyXML can parse XML and XHTML documents with virtually unlimited node depth, provided the document is well-formed. It does not, however, perform validation against DTD or XSLT stylesheets.
MQL5 Integration
The node classes in EasyXML inherit from MQL5's native classes, and nodes are stored efficiently.
When navigating the DOM tree, nodes can be easily manipulated using EasyXML's public methods and MQL5's native functions for retrieving and setting data within the DOM.
URL, File Caching, and Debugging
Recognizing the potential unreliability of RSS feed uptimes, EasyXML offers XML caching. It can save a local cache file of a feed after successfully loading it from a URL for the first time. This cache can be used for parsing if the live feed becomes unavailable.
Given that XML and XHTML documents can sometimes contain errors, EasyXML includes a debugging option. While it cannot repair malformed XML, it significantly aids in identifying the source of errors by providing detailed information about the parsed nodes when enabled.
Additionally, all errors encountered are logged and displayed, regardless of whether debugging is active.
Basic Usage
To begin using EasyXML, simply include the base class in your scripts. Then, create an instance of the EasyXML class. Configure debugging and file caching settings as needed, and call one of the methods to load and parse the XML data.
The examples demonstrate all three loading methods. Typically, you will not need to use all of them simultaneously, though you can clear the DOM tree between operations and parse from a different source using the clear() command.
The setdebugging() and seturlcachefile() methods are optional.
easyxmldocument.getdocumentroot() returns the root node of the DOM tree. All nodes, including the root, are of type ceasyxmlnode, which itself is derived from MQL5's cobject. From this point, you can utilize EasyXML methods alongside native MQL5 functions from carrayobj and cobject to traverse the parsed DOM tree.
Recursive and Inline Reading
The readrecursive() function, called in the examples, offers significant advantages over inline reading for recursive XML document processing, although it may not suit every scenario.
Calling attributes() on a node retrieves all parsed attributes, while children() fetches the child nodes. Both methods return a carrayobj containing the elements. You can iterate through these elements using total() within a for() loop. getname() and getvalue() retrieve the node's content.
Inline node iteration is also possible, functioning similarly to the recursive example but requiring a separate for() loop for each node level.
Step-by-Step DOM Manipulation
You can also navigate the DOM step by step and manipulate individual elements:
This process involves using EasyXML methods in conjunction with native MQL5 iteration and getter/setter functions from cobject and carrayobj.
It is crucial to be aware that some of these functions do not perform memory access validation and may return null if unsuccessful.
For instance, calling childnode.next() on a sibling node without checking for pointer validity can lead to a critical bad pointer fault, potentially crashing the script. Therefore, when manually stepping through or manipulating the DOM tree, always ensure pointer validity for cobject and carrayobj methods.
Key Node Getters
[List of important node getters]
Key Node Setters
[List of important node setters]
For advanced node and node array manipulation, refer to the documentation on relevant classes.
Attribute Getters/Setters
Attribute objects provide the same get/setname() and get/setvalue() methods for data storage and retrieval as node objects.
Disclaimer
This software is under active development and, like all software, may contain bugs or defects. Use EasyXML at your own risk and test thoroughly before integrating it into any live trading systems. Please feel free to contact the developer with any questions or issues.
Credits
The integration of wininet.dll for URL content fetching is used by the library. While this library is built on its own unique parsing system, the documentation on MQL5 string operations from 2026 was a valuable learning resource.
You may also like: easy and fast gu i library for creating graphical interfaces - excellent alternative for library users on MetaTrader 5.
Source Code
#property copyright "robotfx"
#property link "https://robotfx.org"
#property version "1.00"
#include <easyxml\easyxml.mqh>
int readrecursive(ceasyxmlnode *actualnode,int inodelevel=0)
{
string sspace;
string soutput;
stringinit(sspace,inodelevel*4,stringgetcharacter(" ",0));
soutput += sspace + integertostring(inodelevel) + " - node name: '" + actualnode.getname() + "'";
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.