AnyEvent::XMPP::Node(3pm) | User Contributed Perl Documentation | AnyEvent::XMPP::Node(3pm) |
AnyEvent::XMPP::Node - XML node tree helper for the parser.
use AnyEvent::XMPP::Node; ...
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:
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.
See "eq" for the meaning of $namespace_or_alias.
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.
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 :)
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 ta-sa.org>", JID: "<elmex at jabber.org>"
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.
2022-12-06 | perl v5.36.0 |