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

FreeBSD Manual Pages

  
 
  

home | help
XML::TinyXML::Node(3) User Contributed Perl DocumentationXML::TinyXML::Node(3)

NAME
       XML::TinyXML::Node - Tinyxml Node object

SYNOPSIS
	 use XML::TinyXML;

	 # first obtain	an xml context:
	 $xml =	XML::TinyXML->new("rootnode", "somevalue", { attr1 => v1, attr2	=> v2 });

	 # We create a node and	later attach it	to a parent one	doing:
	 $child_node = XML::TinyXML::Node->new("child",	"somevalue");
	 ... [ some code ] ...
	 $parent_node->addChildNode($child_node);

	 # or you can do everything in one go using :
	 $parent_node->addChildNode("child", "somevalue", { attr1 => v1, attr2 => v2 });
	 # the new node	will be	implicitly created within the addChildNode() method

	 # or you can do the other way round, creating the instance of the new childnode
	 # and passing the parent to the constructor which will	take care of calling addChildNode()
	 $child_node = XML::TinyXML::Node->new("child",	"somevalue", $attrs, $parent_node);

	 # we can later	retrive	the "child" node by calling:
	 $child_node = $xml->getNode("/nodelabel/child");
	 # and possibly	modify its value by doing:
	 $child_node->value("othervalue");

	 # at this point , calling :
	 print $xml->dump;
	 # would produce the following xml
	 #
	 # <?xml version="1.0"?>
	 # <rootnode>
	 #   <child>othervalue</child>
	 # </rootnode>

DESCRIPTION
       Node representation for the TinyXML API

INSTANCE VARIABLES
       o   _node

	   Reference to	the underlying XmlNodePtr object (which	is a binding
	   to the XmlNode C structure)

METHODS
       o   new ($entity, $value, $parent, %attrs)

	   Creates a new XML::TinyXML::Node object.

	   $entity can be either a scalar or an	XmlNodePtr object.
	       - if it's a scalar , it will be intepreted as the entity	name
	       - if it's an XmlNodePtr,	it will	be used	as the underlying
	   object
		 and will be incapsulated in the newly created
	   XML::TinyXML::Node object.

	   $value is the optianal string value of the newly created node (the
	   "content" of	the xml	node)

	   if $parent isn't undef the newly created node will be directly
	   attached to the specified parent node. $parent can be either	a
	   XML::TinyXML::Node object or	a XmlNodePtr one.

	   %attrs is an	optional hash specifying attributes for	the newly
	   created xml node

	   Returns a valid XML::TinyXML::Node object

       o   cleanAttributes ()

	   Removes all node attributes

       o   removeAttribute ($index)

	   Removes attribute at	$index

       o   loadHash ($hashref, [ $childname ])

	   Loads an hashref and	represent it as	an xml subbranch.

	   $hashref

	   if $childname is specified, newly created childnodes	will use it as
	   their name

       o   toHash ([ $parent ])

	   Export the xml structure into an hashref (formerly the inverse of
	   loadHash)

	   if $parent is specified the resulting structure will	be connected
	   to $parent.	(NOTE: $parent MUST obviously be an hashref)

       o   updateAttributes (%attrs)

	   Updates all attributes.

	   This	method simply clean all	current	attributes and replace them
	   with	the ones specified in the %attrs hash

       o   addAttributes (%attrs)

	   Add attributes.

       o   name	([$newname])

	   Set/Get the name of a node.	if $newname is specified it will be
	   used	as the new name, otherwise the current name is returned

       o   value ([$newval])

	   Set/Get the vlue of a node.	if $newval is specified	it will	be
	   used	as the new value, otherwise the	current	value is returned

       o   path	()

	   Get the absolute path of a node.

       o   getAttribute	($index)

	   Returns the attribute (XML::TinyXML::NodeAttribute) at index	$index

       o   getAttributes ()

	   Returns all attribute (array/arrayref of
	   XML::TinyXML::NodeAttribute objects)	for this node

       o   attributes ()

	   Returns an hashref copy of all attributes in	this node.

	   The returned	hashref	must be	considered read-only, any change won't
	   be reflected	in the underlying document.

	   If you want to modify the name or the value of an attribute,	use
	   the XML::TinyXML::NodeAttribute api by calling getAttributes() or
	   getAttribute() instead.

       o   getChildNode	($index)

	   Returns child node at $index.  The returned node will be a
	   Xml::TinyXML::Node object

       o   getChildNodeByName ($name)

	   Returns the first child node	whose name matches $name.  The
	   returned node will be a Xml::TinyXML::Node object

       o   countChildren ()

	   Returns the actual number of	children

       o   children ()

	   Returns an array containing all actual children in the form of
	   Xml::TinyXML::Node objects

       o   addChildNode	($child	[, $value [, $attrs ] ])

	   Adds	a new child node.

	   If $child is	an XML::TinyXML::Node object , this will be attached
	   to our children list

	   If $child is	a string (not a	reference) a new node will be created
	   passing $child and the optional $value and $attrs arguments to the
	   constructor and than	attached to the	children list

       o   removeChildNode ($index)

	   Removes child node at provided $index.

       o   removeAllChildren

	   Removes all children	from this node

       o   parent ()

	   Read-Only method which returns the parent node in the form of a
	   XML::TinyXML::Node object.

       o   nextSibling ()

	   Returns the next sibling of this node (if any), undef otherwise.

       o   prevSibling ()

	   Returns the previous	sibling	of this	node (if any), undef
	   otherwise.

       o   type	()

	   Returns the "type" of a XML::TinyXML::Node object.  type can	be :
	       NODE
	       COMMENT
	       CDATA

SEE ALSO
	   XML::TinyXML

AUTHOR
       xant, <xant@cpan.org>

COPYRIGHT AND LICENSE
       Copyright (C) 2008-2010 by xant

       This library is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself, either Perl	version	5.8.8 or, at
       your option, any	later version of Perl 5	you may	have available.

perl v5.32.0			  2013-09-16		 XML::TinyXML::Node(3)

NAME | SYNOPSIS | DESCRIPTION | INSTANCE VARIABLES | METHODS | SEE ALSO | AUTHOR | COPYRIGHT AND LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=XML::TinyXML::Node&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help