NAME

Jabber::Judo::Element - Perl wrapper for the JECL Library judo::Element Object

SYNOPSIS

use Jabber::Judo::Element;

my $e = new Jabber::Judo::Element( "message" );
$e->putAttrib("to", 'piers@jabber.org');
$e->putAttrib("from", 'tester1@jabber.org');
my $e2 = $e->addElement("body");
$e2->addCDATA("Hello World!");
print $e->toString()."\n";

DESCRIPTION

Jabber::Judo::Element is yet another perl implementation for writing Jabber components. How it differs is that it is a wrapper for the high performance JECL libraries for writing components in C++.

Jabber::Judo::Element is the complement for the judo::Element C++ object ( see the judo.h header file for a description ). It elmulates most ( not all ) object methods found here for the creation and manipulating XML packets.

The Methods

Discussion/Explaination of the methods. As far as possible the Author has tried to emulate the judo::* API for XML node manipulation. Some time this is not possible/practical because of the differences between perl and C++

new
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );

 Create an element by passing the name of the tag.
parseAtOnce
 use Jabber::Judo::Element;
 my $e = Jabber::Judo::Element::parseAtOnce( "<message to='blah' from='blah2'><body>Hello</body></message>" );
 print "The Element: ". $e->toString()."\n";

 Take a piece of XML as a string and turn it into a Judo::Element object.
getName
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 print "The tag name: ". $e->getName()."\n";

 Retrieve the name of an Element tag
getChildren
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 foreach ( $e->getChildren() ){
   print "The tag name: ".$_->getName()."\n";
 }

 Get a list of the children elements of this parent element
addCDATA
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 $e1->addCDATA("Hello World!");

 Add the CDATA value to an element - actually returns
 the just added CDATA value as well.
setText
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 $e1->setText("Hello World!");

 Overwrite the CDATA value to an element.
getCDATA
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 $e1->addCDATA("Hello World!");
 print "the CDATA: ".$e1->getCDATA()."\n";

 Retrieve the CDATA value of an element.
addElement
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );

 Add an element as the next child node of the parent
 element.  Returns another Jabber::Judo::Element object.
appendChild
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $ec = new Jabber::Judo::Element( "somechild" );
 $e->appendChild( $ec );

 Copy an element onto another element
findElement
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 my $x = $e->findElement("body");

 Find an element with a given tag name.  Returns 
 another Jabber::Judo::Element object.
delElement
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 $e->delElement("body");
 print "Element gone: ".$e->toString()."\n";

 Delete a given child element from an element.
isEmpty
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 if ( $e->isEmpty() ){
  ....
 }

 Check to see if a node is empty
toString
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 print "Stringified: ". $e->toString()."\n";

 Return a string representation of the XML node
 properly escaped.
size
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e1 = $e->addElement( "body" );
 print "No. of children: ".$e->size()."\n";

 Returns the number of children that a given node has.
putAttrib
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e->putAttrib("to", "piers\@localhost");

 Set the value of an attribute
getAttrib
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e->putAttrib("to", "piers\@localhost");
 print "Attribute to: ".$e->getAttrib("to")."\n";

 Get the value of an attribute
cmpAttrib
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e->putAttrib("to", "piers\@localhost");
 if ( $e->getAttrib("to", "piers\@localhost") ){
   print "Attribute to: ".$e->getAttrib("to")."\n";
 }

 Compare/check the value of an attribute -
 returns true if correct
delAttrib
 use Jabber::Judo::Element;
 my $e = new Jabber::Judo::Element( "message" );
 my $e->putAttrib("to", "piers\@localhost");
 $e->delAttrib("to");
 print "Attributeless element: ".$e->toString()."\n";

 Delete a given attribute from an element.

VERSION

very new

AUTHOR

Piers Harding - but DizzyD ( author of JECL ) is the real star

SEE ALSO

Jabber::JAX::Packet, Jabber::JAX::Component, Jabber::JAX::MyRouterConnection

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 79:

'=item' outside of any '=over'

Around line 491:

You forgot a '=back' before '=head1'