Question
Eduard Lebedyuk · Aug 26, 2020

XML Serialization - output ID

I have a class:

Class test.Person Extends (%Persistent, %XML.Adaptor)
{
Property Name;
}

I want to serialize it into this XML:

<Person>
    <Id>1</Id>
    <Name>Ed</Name>
</Person>

Is it possible?

It's for the Visual Trace so I can't use %XML.Writer.

00
1 0 2 121
Log in or sign up to continue

Replies

Try:

Class test.Person Extends (%Persistent, %XML.Adaptor) { 
Property Id As %Integer [ Calculated, SqlComputeCode = { Set {*}={%%ID}}, SqlComputed ];
Property Name; 
}

if you don't want to touch the Class you may inherit it from some common Super-Class. 

Or

Class Test.Person Extends (%Persistent, %XML.Adaptor)
{ 
Property Name As %String; 
Property Id As %Integer [ Identity ]; 
}