getNodeSet                package:XML                R Documentation

_F_i_n_d _m_a_t_c_h_i_n_g _n_o_d_e_s _i_n _a_n _i_n_t_e_r_n_a_l _X_M_L _t_r_e_e/_D_O_M

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

     This function provides a way to find XML nodes that match a
     particular criterion. It uses the XPath syntax and allows quite
     powerful expressions for identifying nodes.  The XPath language
     requires some knowledge, but tutorials are available.

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

     getNodeSet(doc, path)

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

     doc: an object of class 'XMLInternalDocument'

    path: a string (character vector of length 1) giving the XPath
          expression to evaluate.

_D_e_t_a_i_l_s:

     This calls the libxml routine 'xmlXPathEval'.

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

     The results can currently be different based on the returned value
     from the XPath expression evaluation: 

    list: a node set

 numeric: a number

 logical: a boolean

character: a string, i.e. a single character element.

_N_o_t_e:

     More of the XPath functionality provided by libxml can and may be
     made available to the R package. Facilities such as compiled XPath
     expressions, functions, ordered node information,

     Please send requests to the maintainer.

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

     Duncan Temple Lang <duncan@wald.ucdavis.edu>

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

     <URL: http://xmlsoft.org>,  <URL: http://www.w3.org/xml> <URL:
     http://www.w3.org/TR/xpath> <URL: http://www.omegahat.org/RSXML>

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

     'xmlTreeParse' with 'useInternalNodes' as 'TRUE'.

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

      doc = xmlTreeParse(system.file("exampleData", "tagnames.xml", package = "XML"), useInternalNodes = TRUE)
      getNodeSet(doc, "/doc//b[@status]")
      getNodeSet(doc, "/doc//b[@status='foo']")

      
      els = getNodeSet(doc, "/doc//a[@status]")
      sapply(els, function(el) xmlGetAttr(el, "status"))

