class_docstr: Subclass for formatting data in XML.
  
  Parameters
  ----------
  path_or_buffer : str or file-like
      This can be either a string of raw XML, a valid URL,
      file or file-like object.
  
  index : bool
      Whether to include index in xml document.
  
  row_name : str
      Name for root of xml document. Default is 'data'.
  
  root_name : str
      Name for row elements of xml document. Default is 'row'.
  
  na_rep : str
      Missing data representation.
  
  attrs_cols : list
      List of columns to write as attributes in row element.
  
  elem_cols : list
      List of columns to write as children in row element.
  
  namespaces : dict
      The namespaces to define in XML document as dicts with key
      being namespace and value the URI.
  
  prefix : str
      The prefix for each element in XML document including root.
  
  encoding : str
      Encoding of xml object or document.
  
  xml_declaration : bool
      Whether to include xml declaration at top line item in xml.
  
  pretty_print : bool
      Whether to write xml document with line breaks and indentation.
  
  stylesheet : str or file-like
      A URL, file, file-like object, or a raw string containing XSLT.
  
  {compression_options}
  
      .. versionchanged:: 1.4.0 Zstandard support.
  
  {storage_options}
  
  See also
  --------
  pandas.io.formats.xml.EtreeXMLFormatter
  pandas.io.formats.xml.LxmlXMLFormatter
docstr: Create attributes of row.
  
  This method adds attributes using attr_cols to row element and
  works with tuples for multindex or hierarchical columns.
docstr_tok: ["Create","attributes","of","row",".","This","method","adds","attributes","using","attr_cols","to","row","element","and","works","with","tuples","for","multindex","or","hierarchical","columns","."]
code: def build_attribs(self, d: dict[str, Any], elem_row: Any) -> Any:
      """
      Create attributes of row.
  
      This method adds attributes using attr_cols to row element and
      works with tuples for multindex or hierarchical columns.
      """
  
      if not self.attr_cols:
          return elem_row
  
      for col in self.attr_cols:
          attr_name = self._get_flat_col_name(col)
          try:
              if not isna(d[col]):
                  elem_row.attrib[attr_name] = str(d[col])
          except KeyError:
              raise KeyError(f"no valid column, {col}")
      return elem_row
  
imports: from __future__ import annotations
  import codecs
  import io
  from typing import TYPE_CHECKING, Any
  from pandas._typing import CompressionOptions, FilePath, ReadBuffer, StorageOptions, WriteBuffer
  from pandas.errors import AbstractMethodError
  from pandas.util._decorators import doc
  from pandas.core.dtypes.common import is_list_like
  from pandas.core.dtypes.missing import isna
  from pandas.core.shared_docs import _shared_docs
  from pandas.io.common import get_handle
  from pandas.io.xml import get_data_from_filepath, preprocess_data
label_desc: Use image node_id 9 for calling the BaseXMLFormatter obj's underlying member method code with example usage: obj.build_attribs(d, elem_row) and returns: elem_row, elem_row