NAME
Jabber::Judo::Element - Perl wrapper for the JECL Library judo::Element Object
SYNOPSIS
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!"
);
$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
-
my
$e
= new Jabber::Judo::Element(
"message"
);
Create an element by passing the name of the tag.
- parseAtOnce
-
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
-
my
$e
= new Jabber::Judo::Element(
"message"
);
print
"The tag name: "
.
$e
->getName().
"\n"
;
Retrieve the name of an Element tag
- getChildren
-
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
-
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
-
my
$e
= new Jabber::Judo::Element(
"message"
);
my
$e1
=
$e
->addElement(
"body"
);
$e1
->setText(
"Hello World!"
);
Overwrite the CDATA value to an element.
- getCDATA
-
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
-
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.
- findElement
-
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
-
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
-
my
$e
= new Jabber::Judo::Element(
"message"
);
if
(
$e
->isEmpty() ){
....
}
Check to see
if
a node is empty
- toString
-
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
-
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
-
my
$e
= new Jabber::Judo::Element(
"message"
);
my
$e
->putAttrib(
"to"
,
"piers\@localhost"
);
Set the value of an attribute
- getAttrib
-
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
-
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
-
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 78:
'=item' outside of any '=over'
- Around line 470:
You forgot a '=back' before '=head1'