GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  ANYEVENT::XMPP::NODE (3)

.ds Aq ’

NAME

AnyEvent::XMPP::Node - XML node tree helper for the parser.

CONTENTS

SYNOPSIS



   use AnyEvent::XMPP::Node;
   ...



DESCRIPTION

This class represens a XML node. AnyEvent::XMPP 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 AnyEvent::XMPP should rather take care of it drop me a mail, feature request or most preferably a patch!

Every AnyEvent::XMPP::Node has a namespace, attributes, text and child nodes.

You can access these with the following methods:

METHODS

<B>new ($ns, B>$el<B>, B>$attrs<B>, B>$parser<B>)B> Creates a new AnyEvent::XMPP::Node object with the node tag name $el in the namespace URI $ns and the attributes $attrs. The $parser must be the instance of AnyEvent::XMPP::Parser which generated this node.
<B>nameB> The tag name of this node.
<B>namespaceB> Returns the namespace URI of this node.
<B>eq ($namespace_or_alias, B>$name<B>) or eq ($node)B> 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 AnyEvent::XMPP::Namespaces or pass an namespace URI in $namespace_or_alias. If no alias with the name $namespace_or_alias was found in AnyEvent::XMPP::Namespaces it will be interpreted as namespace URI.

The first argument to eq can also be another AnyEvent::XMPP::Node instance.

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

See eq for the meaning of $namespace_or_alias.

<B>attr ($name)B> Returns the contents of the $name attribute.
<B>add_node ($node)B> Adds a sub-node to the current node.
<B>nodesB> Returns a list of sub nodes.
<B>add_text ($string)B> Adds character data to the current node.
<B>textB> Returns the text for this node.
<B>find_all (@path)B> 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.

<B>write_on ($writer)B> This writes the current node out to the AnyEvent::XMPP::Writer object in $writer.
<B>as_string ()B> 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 :)

<B>append_raw ($string)B> This method is called by the parser to store original strings of this element.
<B>to_sax_events ($handler)B> This method takes anything that can receive SAX events. See also XML::GDOME::SAX::Builder or XML::Handler::BuildDOM or XML::LibXML::SAX::Builder.

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";



AUTHOR

Robin Redeker, <elmex at ta-sa.org>, JID: <elmex at jabber.org>

COPYRIGHT & LICENSE

Copyright 2007, 2008 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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 ANYEVENT::XMPP::NODE (3) 2012-12-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.