turn-key export of data for XML-enabled class?
An XML-enabled class has an XMLExport() method that knows how to serialize an instance to XML. To export all instances of a class to a file, I need to instantiate a writer and loop through the extent. Is there no class method like XMLExportToFile() that does this in one go?
Since XMLEnabled class can be not persistent and, therefore, not have an extent at all, there is no such method. If you need to write XMLExportToFile() for several classes you can write method generator which generates a method that would:
And inherit all classes, in which you have a need of XMLExportToFile() method from this class.
I meant: write a new class with method generator. And inherit from it.
Hi Jon,
I'm not sure this is exactly what you were looking for but you should be aware of the %XML.DataSet class.
With this class you can run an SQL query (for example returning all the instances of your class, or filter out some subset of it) and get the results in XML format (including the metadata of the result).
See more details in the docs.
Here's a sample run: