我试图在Delphi XE或更高版本中使用增强的RTTI功能来读取和写入XML对象.到目前为止,我已成功使用整数,浮点数,字符串,枚举类型,集合和类,但无法正确输出或读取记录.问题似乎是获取记录属性的实例(指针).
//Outputs Properties To XML
procedure TMyBase.SaveToXML(node: TJclSimpleXMLElem);
var
child , subchild : TjclSimpleXMLElem ;
FContext : TRttiContext ;
FType : TRttiType ;
FProp : TRttiProperty ;
Value : TValue ;
MyObj : TMyBase ;
FField : TRttiField ;
FRecord : TRttiRecordType ;
Data : TValue ;
begin
FContext := TRttiContext.Create ;
FType := FContext.GetType ( self.ClassType ) ;
Child := node.Items.Add ( ClassName ) ;
for FProp in FType.GetProperties do begin
if FProp.IsWritable then begin
case FProp.PropertyType.TypeKind of …Run Code Online (Sandbox Code Playgroud)