[Xml-compile] "inheriting" toXML ?

Karen Etheridge perl at froods.org
Tue Oct 23 19:54:47 GMT 2012


On Tue, Oct 23, 2012 at 02:33:20PM -0500, E R wrote:
> On Tue, Oct 23, 2012 at 2:22 PM, Mark Overmeer <mark at overmeer.net> wrote:
> 
> > Or, you could base all your types of some base-class (very common to
> > have such in OO structures) which implements the identity toXML().
> 
> I've been trying to figure out how to write toXML() to be the
> identity. How would you do that?

It entirely depends on what your class looks like and what data you have
stored in it. Basically, you just need to do:

    package MyClass;

    ...

    sub toXML
    {
        my $self = shift;

        # return valid XML based on data stored on $self
        my $xml = ...;
    }




More information about the Xml-compile mailing list