Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
Net::XMPP2::Node(3)   User Contributed Perl Documentation  Net::XMPP2::Node(3)

       Net::XMPP2::Node	- XML node tree	helper for the parser.

	  use Net::XMPP2::Node;

       This class represens a XML node.	Net::XMPP2 should usually not require
       messing with the	parse tree, but	sometimes it is	neccessary.

       If you experience any need for messing with these and feel Net::XMPP2
       should rather take care of it drop me a mail, feature request or	most
       preferably a patch!

       Every Net::XMPP2::Node has a namespace, attributes, text	and child

       You can access these with the following methods:

       new ($ns, $el, $attrs, $parser)
	   Creates a new Net::XMPP2::Node object with the node tag name	$el in
	   the namespace URI $ns and the attributes $attrs. The	$parser	must
	   be the instance of "Net::XMPP2::Parser" which generated this	node.

	   The tag name	of this	node.

	   Returns the namespace URI of	this node.

       eq ($namespace_or_alias,	$name) or eq ($node)
	   Returns true	whether	the current element matches the	tag name $name
	   in the namespaces pointed at	by $namespace_or_alias.

	   You can either pass an alias	that was defined in
	   Net::XMPP2::Namespaces or pass an namespace URI in
	   $namespace_or_alias.	If no alias with the name $namespace_or_alias
	   was found in	Net::XMPP2::Namespaces it will be interpreted as
	   namespace URI.

	   The first argument to eq can	also be	another	Net::XMPP2::Node

       eq_ns ($namespace_or_alias) or eq_ns ($node)
	   This	method return true if the namespace of this instance of
	   Net::XMPP2::Node matches the	namespace described by
	   $namespace_or_alias or the namespace	of the $node which has to be
	   another Net::XMPP2::Node instance.

	   See "eq" for	the meaning of $namespace_or_alias.

       attr ($name)
	   Returns the contents	of the $name attribute.

       add_node	($node)
	   Adds	a sub-node to the current node.

	   Returns a list of sub nodes.

       add_text	($string)
	   Adds	character data to the current node.

	   Returns the text for	this node.

       find_all	(@path)
	   This	method does a recursive	descent	through	the sub-nodes and
	   fetches all nodes that match	the last element of @path.

	   The elements	of @path consist of a array reference to an array with
	   two elements: the namespace key known by the	$parser	and the
	   tagname we search for.

       write_on	($writer)
	   This	writes the current node	out to the Net::XMPP2::Writer object
	   in $writer.

       as_string ()
	   This	method returns the original character representation of	this
	   XML element (and it's children nodes). Please note that the string
	   is a	unicode	string,	meaning: to get	octets use:

	      my $octets = encode ('UTF-8', $node->as_string);

	   Now you can roll stunts like	this:

	      my $libxml = XML::LibXML->new;
	      my $doc	 = $libxml->parse_string (encode ('UTF-8', $node->as_string ()));

	   (You	can use	your favorite XML parser :)

       append_raw ($string)
	   This	method is called by the	parser to store	original strings of
	   this	element.

       to_sax_events ($handler)
	   This	method takes anything that can receive SAX events.  See	also
	   XML::GDOME::SAX::Builder or XML::Handler::BuildDOM or

	   With	this you can convert this node to any DOM level	2 structure
	   you want:

	      my $builder = XML::LibXML::SAX::Builder->new;
	      $node->to_sax_events ($builder);
	      my $dom =	$builder->result;
	      print "Canonized:	" . $dom->toStringC14N . "\n";

       Robin Redeker, "<elmex at>", JID: "<elmex at>"

       Copyright 2007 Robin Redeker, all rights	reserved.

       This program is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

perl v5.32.1			  2007-10-16		   Net::XMPP2::Node(3)


Want to link to this manual page? Use this URL:

home | help