xmlTreeView           package:RGtkViewers           R Documentation

_D_i_s_p_l_a_y _a _G_U_I _t_r_e_e _r_e_p_r_e_s_e_n_t_i_n_g _a_n _X_M_L _h_i_e_r_a_r_c_h_y

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

     This displays a top-level window containing a scrolling 'GtkTree'
     object that represents the hierarchy of an XML document or node.

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

     xmlTreeView(doc, createItem = function(x) gtkTreeItem(xmlName(x)))

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

     doc: the source of the XML nodes. This can be the name of a file
          or URI in which case that document is read, or it can be the
          result from an earlier call to  'xmlTreeParse.' or 'xmlRoot',
          i.e. an 'XMLDocument' 'XMLNode' object.

createItem: a function that is used to create the 'GtkTreeItem' from
          the 'XMLNode' object. This makes it easy to create different
          views of the nodes and to specify any callbacks to customize
          the behavior of the nodes in the tree. See 'xmlView' which is
          the function that uses this. 

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

     An list containing the 'GtkWindow' and the 'GtkTree' objects.

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

     Duncan Temple Lang <duncan@research.bell-labs.com>

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

     <URL: http://www.omegahat.org/RGtk> <URL:
     http://www.omegahat.org/RSXML>

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

     'xmlView' 'xmlTreeParse'

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

        # basic view that uses the xmlName() value of a node.
       xmlTreeView("http://www.ggobi.org/data/flea.xml")

        # customized view that uses the xmlName() and class of the node
       xmlTreeView("http://www.ggobi.org/data/flea.xml",
                    createItem = function(x)
                                    gtkTreeItem(paste(xmlName(x), class(x)[1], sep=":"))) 

        # basic view that uses the xmlName() value of a node.
       xmlTreeView("http://www.ggobi.org/data/flea.xml",
                    createItem = function(x) {
                                   it <- gtkTreeItem(xmlName(x))
                                   if(inherits(x, "XMLTextNode"))
                                     it$AddCallback("select",
                                                     function(node, w) {
                                                       print(xmlValue(node))
                                                     }, data = x)
                                   it
                                 })

