Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

xml::stream::node(3pm) [debian man page]

XML::Stream::Node(3pm)					User Contributed Perl Documentation				    XML::Stream::Node(3pm)

NAME
XML::Stream::Node - Functions to make building and parsing the tree easier to work with. SYNOPSIS
Just a collection of functions that do not need to be in memory if you choose one of the other methods of data storage. This creates a hierarchy of Perl objects and provides various methods to manipulate the structure of the tree. It is much like the C library libxml. FORMAT
The result of parsing: <foo><head id="a">Hello <em>there</em></head><bar>Howdy<ref/></bar>do</foo> would be: [ tag: foo att: {} children: [ tag: head att: {id=>"a"} children: [ tag: "__xmlstream__:node:cdata" children: "Hello " ] [ tag: em children: [ tag: "__xmlstream__:node:cdata" children: "there" ] ] ] [ tag: bar children: [ tag: "__xmlstream__:node:cdata" children: "Howdy " ] [ tag: ref ] ] [ tag: "__xmlstream__:node:cdata" children: "do" ] ] METHODS
new() - creates a new node. If you specify tag, then the root new(tag) tag is set. If you specify data, then cdata is added new(tag,cdata) to the node as well. Returns the created node. get_tag() - returns the root tag of the node. set_tag(tag) - set the root tag of the node to tag. add_child(node) - adds the specified node as a child to the current add_child(tag) node, or creates a new node with the specified tag add_child(tag,cdata) as the root node. Returns the node added. remove_child(node) - removes the child node from the current node. remove_cdata() - removes all of the cdata children from the current node. add_cdata(string) - adds the string as cdata onto the current nodes child list. get_cdata() - returns all of the cdata children concatenated together into one string. get_attrib(attrib) - returns the value of the attrib if it is valid, or returns undef is attrib is not a real attribute. put_attrib(hash) - for each key/value pair specified, create an attribute in the node. remove_attrib(attrib) - remove the specified attribute from the node. add_raw_xml(string,[string,...]) - directly add a string into the XML packet as the last child, with no translation. get_raw_xml() - return all of the XML in a single string, undef if there is no raw XML to include. remove_raw_xml() - remove all raw XML strings. children() - return all of the children of the node in a list. attrib() - returns a hash containing all of the attributes on this node. copy() - return a recursive copy of the node. XPath(path) - run XML::Stream::XPath on this node. XPathCheck(path) - run XML::Stream::XPath on this node and return 1 or 0 to see if it matches or not. GetXML() - return the node in XML string form. AUTHOR
By Ryan Eatmon in June 2002 for http://jabber.org/ Currently maintained by Darian Anthony Patrick. COPYRIGHT
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2010-01-08 XML::Stream::Node(3pm)

Check Out this Related Man Page

POE::Filter::XML::Node(3pm)				User Contributed Perl Documentation			       POE::Filter::XML::Node(3pm)

NAME
POE::Filter::XML::Node - An enhanced XML::LibXML::Element subclass. SYNOPSIS
use 5.010; use POE::Filter::XML::Node; my $node = POE::Filter::XML::Node->new('iq'); $node->setAttributes( ['to', 'foo@other', 'from', 'bar@other', 'type', 'get'] ); my $query = $node->addNewChild('jabber:iq:foo', 'query'); $query->appendTextChild('foo_tag', 'bar'); say $node->toString(); -- (newlines and tabs for example only) <iq to='foo@other' from='bar@other' type='get'> <query xmlns='jabber:iq:foo'> <foo_tag>bar</foo_tag> </query> </iq> DESCRIPTION
POE::Filter::XML::Node is a XML::LibXML::Element subclass that aims to provide a few extra convenience methods and light integration into a streaming context. METHODS
stream_start($bool) [public] stream_start() called without arguments returns a bool on whether or not the node in question is the top level document tag. In an xml stream such as XMPP this is the <stream:stream> tag. Called with a single argument (a bool) sets whether this tag should be considered a stream starter. This method is significant because it determines the behavior of the toString() method. If stream_start() returns bool true, the tag will not be terminated. (ie. <iq to='test' from='test'> instead of <iq to='test' from='test'/>) stream_end($bool) [public] stream_end() called without arguments returns a bool on whether or not the node in question is the closing document tag in a stream. In an xml stream such as XMPP, this is the </stream:stream>. Called with a single argument (a bool) sets whether this tag should be considered a stream ender. This method is significant because it determines the behavior of the toString() method. If stream_end() returns bool true, then any data or attributes or children of the node is ignored and an ending tag is constructed. (ie. </iq> instead of <iq to='test' from='test'><child/></iq>) setAttributes($array_ref) [public] setAttributes() accepts a single arguement: an array reference. Basically you pair up all the attributes you want to be into the node (ie. [attrib, value]) and this method will process them using setAttribute(). This is just a convenience method. If one of the attributes is 'xmlns', setNamespace() will be called with the value used as the $nsURI argument, with no prefix, and not activated. eg. ['xmlns', 'http://foo'] | V setNamespace($value, '', 0) | V <node xmlns="http://foo"/> getAttributes() [public] This method returns all of the attribute nodes on the Element (filtering out namespace declarations). getChildrenHash() [public] getChildrenHash() returns a hash reference to all the children of that node. Each key in the hash will be node name, and each value will be an array reference with all of the children with that name. Each child will be blessed into POE::Filter::XML::Node. getSingleChildByTagName($name) [public] This is a convenience method that basically does: (getChildrenByTagName($name))[0] The returned object will be a POE::Filter::XML::Node object. new($name,[$array_ref]) [overriden] The default XML::LibXML::Element constructor is overridden to provide some extra functionality with regards to attributes. If the $array_ref argument is defined, it will be passed to setAttributes(). Returns a newly constructed POE::Filter::XML::Node. cloneNode($deep) [overridden] This method overrides the base cloneNode() to propogate the stream_[start|end] bits on the node being cloned. The $deep argument is passed unchanged to the base class. This returns a POE::Filter::XML::Node object. appendChild($name|$node,[$array_ref]) [overridden] Depending on the arguments provided, this method either 1) instantiates a new Node and appends to the subject or 2) appends the provided Node object. An array reference of attributes may also be provided in either case, and if defined, will be passed to setAttributes(). toString($formatted) [overridden] toString() was overridden to provide special stringification semantics for when stream_start and stream_end are boolean true. FUNCTIONS
ordain($element) [exported by default] Use this exported function to get PFX::Nodes from XML::LibXML::Elements. This is useful for inherited methods that by default return Elements instead of Nodes. NOTES
This Node module is 100% incompatible with previous versions. Do NOT assume this will upgrade cleanly. When using XML::LibXML::Element methods, the objects returned will NOT be blessed into POE::Filter::XML::Node objects unless those methods are explictly overriden in this module. Use POE::Filter::XML::Node::ordain to overcome this. AUTHOR
Copyright (c) 2003 - 2009 Nicholas Perez. Released and distributed under the GPL. perl v5.10.0 2009-04-25 POE::Filter::XML::Node(3pm)
Man Page