xmlAttrs                 package:XML                 R Documentation

_G_e_t _t_h_e _l_i_s_t _o_f _a_t_t_r_i_b_u_t_e_s _o_f _a_n _X_M_L _n_o_d_e.

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

     This returns a named character vector giving the  name-value pairs
     of attributes of an XMLNode object which is part of an XML
     document.

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

      xmlAttrs(node, ...)
      'xmlAttrs<-'(node, append = TRUE, suppressNamespaceWarning = getOption("suppressXMLNamespaceWarning", FALSE), value)

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

    node: The 'XMLNode' object whose attributes are to be extracted. 

  append: a logical value indicating whether to add the attributes in
          'value' to the existing attributes  within the XML node, or
          to replace the set of any existing attributes with this new
          set, i.e. remove the existing ones and  then set the
          attributes with the contents of 'value'.

     ...: additional arguments for the specific methods, currently
          ignored but present for future extensions.

   value: a named character vector giving the new attributes to be
          added to the node.

suppressNamespaceWarning: see 'addChildren'

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

     A named character vector, where the names are the attribute names
     and the  elements are the corresponding values. This corresponds
     to the (attr<i>, "value<i>") pairs in the XML tag '<tag
     attr1="value1"  attr2="value2"'

_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:

     'xmlChildren', 'xmlSize', 'xmlName'

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

      fileName <- system.file("exampleData", "mtcars.xml", package="XML") 
      doc <- xmlTreeParse(fileName)

      xmlAttrs(xmlRoot(doc))

      xmlAttrs(xmlRoot(doc)[["variables"]])

      doc <- xmlTreeParse(fileName, useInternalNodes = TRUE)
      d = xmlRoot(doc)

      xmlAttrs(d)
      xmlAttrs(d) <- c(name = "Motor Trend fuel consumption data",
                       author = "Motor Trends")
      xmlAttrs(d)

        # clear all the attributes and then set new ones.
      removeAttributes(d)
      xmlAttrs(d) <- c(name = "Motor Trend fuel consumption data",
                       author = "Motor Trends")

