거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

XML parser - MetaTrader 5용 라이브러리

조회수:
5894
평가:
(31)
게시됨:
2011.11.29 13:46
업데이트됨:
2016.11.22 07:32
\MQL5\Include\XML\
xmlbase.mqh (0.56 KB) 조회
xmldocument.mqh (11.89 KB) 조회
xmlelement.mqh (18.89 KB) 조회
\MQL5\Scripts\
xml_test.mq5 (1.39 KB) 조회
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

A library for parsing of XML documents. Pure MQL5, it doesn't uses any external libraries.

To use the library, just include it:

#include <Xml\XmlBase.mqh>

Example:

#include <Xml\XmlBase.mqh>

CXmlDocument doc;

void OnStart() 
{
  string file = "File.xml";
  string err;
  if (doc.CreateFromText(file,err))
  {
    CXmlElement * xmlItem = doc.FDocumentElement.GetChild(0);
    for (int i=0; i<xmlItem.GetChildCount(); i++) 
    if (xmlItem.GetChild(i).GetName() == "LAYER")
    {
      CXmlElement* layer = xmlItem.GetChild(i);
      for (int j=0; j<layer.GetChildCount(); ++j) 
      {        
        if (layer.GetChild(j).GetName() == "NEURON")
        {
           /* .... */
        }
      }
    }
  }
}

Notes:

  • The library was written when constuctors in MQL5 were without parameters;
  • Only basic functions of Xml standard is supported;
  • Plese inform me about errors, suggestions and bug fixes.

Main components:

CXmlDocument class provides methods for downloading of XML documents from file/string and save to file.

CreateX functions parses XML documents and create hierarchy of DOM model, the working with it can be done using FDocumentElement 

class CXmlDocument 
{
  private:

    void DoElementTrimText(CXmlElement &aXmlItem) ;
  
  public:
    CXmlElement FDocumentElement;

    void CXmlDocument ();
    void ~CXmlDocument ();
    void Clear();
    void CopyTo (CXmlDocument &xmlDoc);
  
    bool  CreateFromText (const string& xml, string& err);
    bool  CreateFromFile (const string filename, string& err);
    bool  SaveToFile (const string filename);

    string GetXml();
};

 

CXmlElement class is a base interface of any XML document. It provides access to elements, attributes and content

class CXmlElement 
{
  private:
    string         FName;
    CXmlAttribute* FAttributes[];
    CXmlElement   *FElements[];
    string         FText;
    CXmlElement*   FParent;
  public:  
    //--- constructor methods
    void  CXmlElement ();
    void ~CXmlElement ();
    void Init (const string aName, const CXmlElement* aParent=NULL, const string aText="");
    void CopyTo (CXmlElement &aDst);
    virtual void Clear ();
    
    //--- main service methods
    string GetName () const;
    void SetName (const string aName);
    string GetText () const;
    void SetText (const string aText);
    CXmlElement* GetParent () const;
    void SetParent (CXmlElement* aParent);
    
    //--- attribute service methods
    int GetAttributeCount () const;
    int GetAttributeIndex (CXmlAttribute* aAttr) const;
    CXmlAttribute* GetAttribute (const string aName) const;
    CXmlAttribute* GetAttribute (int aPos) const;
    string GetAttributeValue (const string aName) const;
    
    CXmlAttribute* AttributeInsertAt (CXmlAttribute* aAttr, int aPos);
    CXmlAttribute* AttributeAdd (CXmlAttribute* aAttr);
    CXmlAttribute* AttributeInsertAfter (CXmlAttribute* aAfter, CXmlAttribute* aAttr);
    CXmlAttribute* AttributeInsertBefore (CXmlAttribute* aBefore, CXmlAttribute* aAttr);
    CXmlAttribute* AttributeRemove (CXmlAttribute* aAttr);
    CXmlAttribute* AttributeRemove (int aPos);
    void AttributeDelete (CXmlAttribute* aAttr);
    void AttributeDelete (int aPos);
    void AttributeDeleteAll ();
  
    //--- child service methods
    int GetChildCount() const;
    int GetChildIndex (CXmlElement* aElement) const;
    CXmlElement* GetChild (const string aName) const;
    CXmlElement* GetChild (int aPos) const;
    string GetChildText (const string aName) const;

    CXmlElement* ChildInsertAt (CXmlElement* aElement, int aPos);
    CXmlElement* ChildAdd (CXmlElement* aElement);
    CXmlElement* ChildInsertAfter (CXmlElement* aAfter, CXmlElement* aElement);
    CXmlElement* ChildInsertBefore (CXmlElement* aBefore, CXmlElement* aElement);
    CXmlElement* ChildRemove (CXmlElement* aElement);
    CXmlElement* ChildRemove (int aPos);
    void ChildDelete (CXmlElement* aElement);
    void ChildDelete (int aPos);
    void ChildDeleteAll ();
  
    string GetXml(int aLevel);
};

 

CXmlAttribute is a simple class for working with attributes

class CXmlAttribute 
{
  private:
    string FName;
    string FValue;
 public:
    //--- constructor methods
    void CXmlAttribute ();
    void ~CXmlAttribute ();

    void Init (const string aName, const string aValue);
    virtual void Clear ();
    virtual CXmlAttribute* Clone ();
    
    //--- service methods
    string GetName () const;
    void SetName (const string aName);
    string GetValue () const;
    void SetValue (const string aValue);    
};

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/712

Candles Smoothed HTF Candles Smoothed HTF

The indicator that displays "averaged" candlesticks of a larger timeframe at a smaller one.

Magnified Market Price Magnified Market Price

The indicator shows the current price in one of the chart corners.

Three-Pole Super Smoother Filter Three-Pole Super Smoother Filter

Three-pole super smoother filter from John Ehlers' book "Cybernetic Analysis for Stocks and Futures: Cutting-Edge DSP Technology to Improve Your Trading" is used in this indicator for moving average calculation.

JFatlSpeed HTF JFatlSpeed HTF

This indicator shows the direction of the acceleration of JFatlSpeed price from a larger timeframe at a smaller one.