IMetabaseCustomObjectReader.ReadToXML

Fore Syntax

ReadToXML(Var Xml: Variant);

Fore.NET Syntax

ReadToXML(Var Xml: object);

Parameters

Xml. XML object, to which data from the object will be read.

Description

The ReadToXML method reads data from the custom class object in the XML format and loads it to the specified variable.

Comments

Before executing the ReadToStream method, call the Load method to read data from the repository base to the current object in the PC memory.

Fore Example

Executing the example requires that the repository contains a custom class object with the OBJ_CUSTOM identifier.

Add links to the Metabase, Xml system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomObject: IMetabaseCustomObject;
    Writer: IMetabaseCustomObjectWriter;
    Reader: IMetabaseCustomObjectReader;
    XmlVar: Variant;
    xmlDE: IXmlDomElement;
    XmlDoc: FreeThreadedDOMDocument60;
Begin
    Mb := MetabaseClass.Active;
    Object := Mb.ItemById("OBJ_CUSTOM").Edit;
    CustomObject := Object As IMetabaseCustomObject;
    XmlDoc := New FreeThreadedDOMDocument60.Create;
    XmlDoc.loadXML("<nodes> <node1>ITEM1=3</node1> <node2>ITEM2=0</node2> </nodes>");
    Writer := CustomObject.CreateWriter;
    Writer.WriteFromXML(XmlDoc);
    Writer.Save;
    Reader := CustomObject.CreateReader;
    Reader.Load;
    Reader.ReadToXML(XmlVar);
    XmlDoc := XmlVar As FreeThreadedDOMDocument60;
    xmlDE := XmlDoc.selectSingleNode("nodes"As IXmlDomElement;
    Debug.WriteLine(xmlDE.xml);
    Object.Save;
End Sub UserProc;

After executing this example custom data in format XML are written in the object, then these data are read and displayed in the console window.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.MsXml2;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Obj: IMetabaseObject;
    CustomObject: IMetabaseCustomObject;
    Writer: IMetabaseCustomObjectWriter;
    Reader: IMetabaseCustomObjectReader;
    XmlVar: object;
    xmlDE: IXmlDomElement;
    XmlDoc: FreeThreadedDOMDocument60;
Begin
    Mb := Params.Metabase;
    Obj := Mb.ItemById["OBJ_CUSTOM"].Edit();
    CustomObject := Obj As IMetabaseCustomObject;
    XmlDoc := New FreeThreadedDOMDocument60.Create();
    XmlDoc.loadXML("<nodes> <node1>ITEM1=3</node1> <node2>ITEM2=0</node2> </nodes>");
    Writer := CustomObject.CreateWriter();
    Writer.WriteFromXML(XmlDoc);
    Writer.Save();
    Reader := CustomObject.CreateReader();
    Reader.Load();
    Reader.ReadToXML(Var XmlVar);
    XmlDoc := XmlVar As FreeThreadedDOMDocument60;
    xmlDE := XmlDoc.selectSingleNode("nodes"As IXmlDomElement;
    System.Diagnostics.Debug.WriteLine(xmlDE.xml);
    Obj.Save();
End Sub;

See also:

IMetabaseCustomObjectReader