addNode                 package:XML                 R Documentation

_A_d_d _a _n_o_d_e _t_o _a _t_r_e_e

_D_e_s_c_r_i_p_t_i_o_n:

     This generic function allows us to add a node to a tree for
     different types of trees. Currently it just works for XMLHashTree,
     but it could be readily extended to the more general XMLFlatTree
     class. However, the concept in this function is to change the tree
     and return the node. This does not work unless the tree is
     directly mutable without requiring reassignment, i.e. the changes
     do not induce a new copy of the original tree object. DOM trees
     which are lists of lists of lists do not fall into this category.

_U_s_a_g_e:

     addNode(node, parent, to)

_A_r_g_u_m_e_n_t_s:

    node: the node to be added as a child of the parent.

  parent: the parent node or identifier

      to: the tree object

_V_a_l_u_e:

     The new node object. For flat trees, this will be the 'node' after
     it has been coerced to be compatible with a flat tree, i.e. has an
     id and the host tree added to it.

_A_u_t_h_o_r(_s):

     Duncan Temple Lang

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://www.w3.org>

_S_e_e _A_l_s_o:

     'xmlHashTree' 'asXMLTreeNode'

_E_x_a_m_p_l_e_s:

       tt = xmlHashTree()

       top = addNode(xmlNode("top"), character(), tt)
       addNode(xmlNode("a"), top, tt)
       b = addNode(xmlNode("b"), top, tt)
       c = addNode(xmlNode("c"), b, tt)
       addNode(xmlNode("c"), top, tt)
       addNode(xmlNode("c"), b, tt)    
       addNode(xmlTextNode("Some text"), c, tt)

       xmlElementsByTagName(tt$top, "c")

       tt

