XML::Genx::Simple - A slightly simpler wrapper class for genx


XML-Genx documentation  | view source Contained in the XML-Genx distribution.

Index


NAME

Top

XML::Genx::Simple - A slightly simpler wrapper class for genx

SYNOPSIS

Top

  use XML::Genx::Simple;
  my $w = XML::Genx::Simple->new;
  eval {
    # <root><foo id="1">bar</foo></root>
    $w->StartDocFile( *STDOUT );
    $w->StartElementLiteral( 'root' );
    $w->Element( foo => 'bar', id => 1 );
    $w->EndElement;
    $w->EndDocument;
  };
  die "Writing XML failed: $@" if $@;

DESCRIPTION

Top

This class provides some helper methods to make using XML::Genx simpler in the common case.

METHODS

Top

StartDocString ( )

Starts a new document, and collects the result into a string.

This method is offered as an extension to the genx API since it is significantly quicker. Many thanks to A. Pagaltzis for suggesting it.

GetDocString ( )

Returns the string from the current writer object.

NB: This is only guaranteed to be well-formed XML after you have called EndDocument().

NB: This will only produce sensible output if you've called StartDocString() previously.

Element ( NAME, TEXT, [ATTRS] )

Outputs <NAME>TEXT</NAME> in one go. NAME can be either a text string or an XML::Genx::Element object.

If NAME is a text string, an XML::Genx::Element object will be created, used and cached. So there's no real advantage to passing one in.

Optionally, ATTRS can be passed in as a list of key/value pairs. Again, each key used as an attribute name will be cached.

This method provides no namespace support.

SEE ALSO

Top

XML::Genx.

AUTHOR

Top

Dominic Mitchell, <cpan (at) happygiraffe.net>

The genx library was created by Tim Bray http://www.tbray.org/.

COPYRIGHT AND LICENSE

Top

VERSION

Top

@(#) $Id: Simple.pm 1270 2006-10-08 17:29:33Z dom $


XML-Genx documentation  | view source Contained in the XML-Genx distribution.