XML-DOM2

 view release on metacpan or  search on metacpan

lib/XML/DOM2/Element/CDATA.pm  view on Meta::CPAN

package XML::DOM2::Element::CDATA;

=head1 NAME

  XML::DOM2::Element::CDATA

=head1 DESCRIPTION

  CDATA Element object class

=head1 METHODS

=cut

use base "XML::DOM2::Element";

use strict;
use warnings;

use overload
	'""' => sub { shift->auto_string( @_ ) },
	'eq' => sub { shift->auto_eq( @_ ) },
	'ne' => sub { not shift->auto_eq( @_ ) };

=head2 $class->new( $text, %arguments )

  Create a new cdata object.

=cut
sub new
{
	my ($proto, $text, %args) = @_;
	$args{'text'} = $text;
	my $self = $proto->SUPER::new('cdata', %args);
	return $self;
}

=head2 $element->xmlify()

  Returns the text as a serialised xml string (serialisation)

=cut
sub xmlify
{
	my ($self, %p) = @_;
	my $sep = $p{'seperator'};
	my $text = $self->text();
	if($self->{'notag'}) {
		return $sep.'<![CDATA['.$text.']]>'.$sep;
	} elsif($self->{'noescape'}) {
		return $text;
	}
	return $text;
}

=head2 $element->text()

  Return plain text (UTF-8)

=cut
sub text
{
	my ($self) = @_;
	return $self->{'text'};
}

=head2 $element->setData( $text )

  Replace text data with $text.

=cut
sub setData
{
	my ($self, $text) = @_;
	$self->{'text'} = $text;
}

=head2 $element->appendData( $text )

  Append to the end of the data $text.

=cut
sub appendData
{
	my ($self, $text) = @_;
	$self->{'text'} .= $text;
}

=head2 $element->_can_contain_elements()

  The element can not contain sub elements.

=cut
sub _can_contain_elements { 0 }



( run in 0.939 second using v1.01-cache-2.11-cpan-39bf76dae61 )