ReadToXML(Var Xml: Variant);
Xml. XML object, to which data from the object will be read.
The ReadToXML method reads data from the custom class object in the XML format and loads it to the specified variable.
Before executing the ReadToStream method, call the Load method to read data from the repository base to the current object in the PC memory.
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;
CustomObject: IMetabaseCustomObject;
Writer: IMetabaseCustomObjectWriter;
Reader: IMetabaseCustomObjectReader;
XmlVar: Variant;
XmlDE: IXmlDomElement;
XmlDoc: FreeThreadedDOMDocument60;
Begin
Mb := MetabaseClass.Active;
CustomObject := Mb.ItemById("OBJ_CUSTOM").Edit 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);
(CustomObject As IMetabaseObject).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: