IMetabaseCustomObjectReader.ReadToXML

Syntax

ReadToXML(Var Xml: Variant);

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.

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 the example custom data in format XML are written in the object, then these data are read and displayed in the console window.

See also:

IMetabaseCustomObjectReader