a
    Sic<                     @  s  d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZ ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& e	rddl'm(Z( ddl)m*Z*m+Z+ ddl,m-Z- eed ed d dG dd dZ.G dd de.Z/G dd de.Z0ddddddd d!Z1d"d#d$d%Z2d&d#d'd(Z3d)d*d+d,d,d-d.d/d0dd1d2d3ddd&d4d5d6Z4eddgd7eed ed d dd?d)d*d+d,d,d-d.d/d0dd1d2d3ddd&d4d=d>Z5dS )@z3
:mod:`pandas.io.xml` is a module for reading XML.
    )annotationsN)AnyCallableSequence)	TYPE_CHECKINGCompressionOptionsConvertersArgDtypeArgFilePathParseDatesArg
ReadBufferStorageOptions
XMLParsers)import_optional_dependency)AbstractMethodErrorParserError)deprecate_nonkeyword_argumentsdoc)is_list_like)_shared_docs)file_exists
get_handleinfer_compressionis_fsspec_urlis_urlstringify_path)
TextParser)Element)_Element_XSLTResultTree)	DataFramestorage_optionsdecompression_optionspath_or_buffer)r!   r"   c                   @  s   e Zd ZdZddddddddd	d
ddddddddZddddZdddddZdddddZdddd Zddd!d"Z	dd#d$d%d&Z
d'S )(_XMLFrameParserab	  
    Internal subclass to parse XML into DataFrames.

    Parameters
    ----------
    path_or_buffer : a valid JSON str, path object or file-like object
        Any valid string path is acceptable. The string could be a URL. Valid
        URL schemes include http, ftp, s3, and file.

    xpath : str or regex
        The XPath expression to parse required set of nodes for
        migration to `Data Frame`. `etree` supports limited XPath.

    namespaces : dict
        The namespaces defined in XML document (`xmlns:namespace='URI')
        as dicts with key being namespace and value the URI.

    elems_only : bool
        Parse only the child elements at the specified `xpath`.

    attrs_only : bool
        Parse only the attributes at the specified `xpath`.

    names : list
        Column names for Data Frame of parsed XML data.

    dtype : dict
        Data type for data or columns. E.g. {{'a': np.float64,
        'b': np.int32, 'c': 'Int64'}}

        .. versionadded:: 1.5.0

    converters : dict, optional
        Dict of functions for converting values in certain columns. Keys can
        either be integers or column labels.

        .. versionadded:: 1.5.0

    parse_dates : bool or list of int or names or list of lists or dict
        Converts either index or select columns to datetimes

        .. versionadded:: 1.5.0

    encoding : str
        Encoding of xml object or document.

    stylesheet : str or file-like
        URL, file, file-like object, or a raw string containing XSLT,
        `etree` does not support XSLT but retained for consistency.

    iterparse : dict, optional
        Dict with row element as key and list of descendant elements
        and/or attributes as value to be retrieved in iterparsing of
        XML document.

        .. versionadded:: 1.5.0

    {decompression_options}

        .. versionchanged:: 1.4.0 Zstandard support.

    {storage_options}

    See also
    --------
    pandas.io.xml._EtreeFrameParser
    pandas.io.xml._LxmlFrameParser

    Notes
    -----
    To subclass this class effectively you must override the following methods:`
        * :func:`parse_data`
        * :func:`_parse_nodes`
        * :func:`_iterparse_nodes`
        * :func:`_parse_doc`
        * :func:`_validate_names`
        * :func:`_validate_path`


    See each method's respective documentation for details on their
    functionality.
    .FilePath | ReadBuffer[bytes] | ReadBuffer[str]strdict[str, str] | NoneboolSequence[str] | NoneDtypeArg | NoneConvertersArg | NoneParseDatesArg | None
str | None5FilePath | ReadBuffer[bytes] | ReadBuffer[str] | Nonedict[str, list[str]] | Noner   r   None)r#   xpath
namespaces
elems_only
attrs_onlynamesdtype
convertersparse_datesencoding
stylesheet	iterparsecompressionr!   returnc                 C  s^   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _d | _|| _|| _d S N)r#   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   Zis_styler<   r!   )selfr#   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r!    r@   I/var/www/html/django/DPS/env/lib/python3.9/site-packages/pandas/io/xml.py__init__   s    z_XMLFrameParser.__init__list[dict[str, str | None]]r=   c                 C  s   t | dS )z
        Parse xml data.

        This method will call the other internal methods to
        validate xpath, names, parse and return specific nodes.
        Nr   r?   r@   r@   rA   
parse_data   s    z_XMLFrameParser.parse_dataz	list[Any])elemsr=   c                   s   j rjrtdnnj rFjr6fdd|D }qdd |D }n>jr\dd |D }n(jrvfdd|D }ndd |D }dd |D }ttd	d |D   fd
d|D }jrԇfdd|D }|S )a=  
        Parse xml nodes.

        This method will parse the children and attributes of elements
        in xpath, conditionally for only elements, only attributes
        or both while optionally renaming node names.

        Raises
        ------
        ValueError
            * If only elements and only attributes are specified.

        Notes
        -----
        Namespace URIs will be removed from return node values. Also,
        elements with missing children or attributes compared to siblings
        will have optional keys filled with None values.
        z4Either element or attributes can be parsed not both.c              	     sP   g | ]H}i |j r*|j  s*|j|j  ini d d t j|dD qS )c                 S  s&   i | ]\}}||j r|j  nd qS r>   textstrip.0nmchr@   r@   rA   
<dictcomp>   s   ;_XMLFrameParser._parse_nodes.<locals>.<listcomp>.<dictcomp>*)rJ   isspacetagrK   zipr5   findallrM   elrF   r@   rA   
<listcomp>   s   z0_XMLFrameParser._parse_nodes.<locals>.<listcomp>c                 S  s    g | ]}d d | dD qS )c                 S  s$   i | ]}|j |jr|j nd qS r>   rT   rJ   rK   rM   rO   r@   r@   rA   rP      s   rQ   rR   )rV   rW   r@   r@   rA   rY      s   c                 S  s    g | ]}d d |j  D qS )c                 S  s"   i | ]\}}||r|  nd qS r>   )rK   rM   kvr@   r@   rA   rP          rQ   )attribitemsrW   r@   r@   rA   rY      s   c              	     sV   g | ]N}i |j |jr0|j s0|j|j ini d d t j|dD qS )c                 S  s&   i | ]\}}||j r|j  nd qS r>   rI   rL   r@   r@   rA   rP      s   rQ   rR   )r`   rJ   rS   rT   rK   rU   r5   rV   rW   rF   r@   rA   rY      s   c                 S  sN   g | ]F}i |j |jr0|j s0|j|j ini d d |dD qS )c                 S  s$   i | ]}|j |jr|j nd qS r>   rZ   r[   r@   r@   rA   rP     s   rQ   rR   )r`   rJ   rS   rT   rK   rV   rW   r@   r@   rA   rY   	  s   c                 S  s   g | ]}d d |  D qS )c                 S  s,   i | ]$\}}d |v r"| d d n||qS )}   )splitr\   r@   r@   rA   rP     r_   rQ   )ra   rM   dr@   r@   rA   rY     s   c                 S  s   g | ]}|  D ]}|qqS r@   keysrM   rf   r]   r@   r@   rA   rY     r_   c                   s   g | ]  fd dD qS )c                   s&   i | ]}||   v r | nd qS r>   rg   rM   r]   rf   r@   rA   rP     r_   rQ   r@   rM   rg   rk   rA   rY     r_   c                   s&   g | ]}d d t  j| D qS )c                 S  s   i | ]\}}||qS r@   r@   rM   rN   r^   r@   r@   rA   rP   !  r_   rQ   rU   r5   valuesre   rF   r@   rA   rY   !  r_   )r3   r4   
ValueErrorr5   listdictfromkeys)r?   rH   dictsr@   rh   r?   rA   _parse_nodes   s:    


z_XMLFrameParser._parse_nodesr   )r;   r=   c                   s  g }d}t jts*ttjj djrBttj nd}t	j| slttj|  dt j
trtj
stj
sj
dstj
ddurtd|j
dd	D ]\}}d
|jv r|jd
d n|j}|dkr||kri }|durjrtj| jD ]\}}	||krj|jrD|j nd}
||	|
krj|	|vrj|
||	< ||jv r |j| | vr |	|vr |j| ||	< q nPj| D ]D}||kr|jr|j nd||< ||jv r|j| ||< q|dkr||kr"|dur"|| d}|  t|dr| dur| dur| d= q4q|g krntdtt dd |D   fdd|D }jrfdd|D }|S )a  
        Iterparse xml nodes.

        This method will read in local disk, decompressed XML files for elements
        and underlying descendants using iterparse, a method to iterate through
        an XML tree without holding entire XML tree in memory.

        Raises
        ------
        TypeError
            * If `iterparse` is not a dict or its dict value is not list-like.
        ParserError
            * If `path_or_buffer` is not a physical, decompressed file on disk.
            * If no data is returned from selected items in `iterparse`.

        Notes
        -----
        Namespace URIs will be removed from return node values. Also,
        elements with missing children or attributes in submitted list
        will have optional keys filled with None values.
        Nz" is not a valid type for iterparse z+ is not a valid type for value in iterparsez<?xml<inferziterparse is designed for large XML files that are fully extracted on local disk and not as compressed files or online sources.)startend)eventsrb   rc   r{   r|   getpreviousr   z+No result from selected items in iterparse.c                 S  s   g | ]}|  D ]}|qqS r@   rg   ri   r@   r@   rA   rY   ~  r_   z4_XMLFrameParser._iterparse_nodes.<locals>.<listcomp>c                   s   g | ]  fd dD qS )c                   s&   i | ]}||   v r | nd qS r>   rg   rj   rk   r@   rA   rP     r_   ?_XMLFrameParser._iterparse_nodes.<locals>.<listcomp>.<dictcomp>r@   rl   rg   rk   rA   rY     r_   c                   s&   g | ]}d d t  j| D qS )c                 S  s   i | ]\}}||qS r@   r@   rm   r@   r@   rA   rP     r_   r   rn   re   rF   r@   rA   rY     r_   )!
isinstancer;   rr   	TypeErrortype__name__nextiterrh   r   r#   r&   r   r   
startswithr   r   rT   rd   r5   rU   rJ   rK   getr`   ro   appendclearhasattrr~   	getparentrq   rs   )r?   r;   rt   rowZrow_nodeeventelemZ	curr_elemcolrN   Zelem_valr@   ru   rA   _iterparse_nodes%  s|    

 







z _XMLFrameParser._iterparse_nodesc                 C  s   t | dS )a&  
        Validate xpath.

        This method checks for syntax, evaluation, or empty nodes return.

        Raises
        ------
        SyntaxError
            * If xpah is not supported or issues with namespaces.

        ValueError
            * If xpah does not return any nodes.
        NrE   rF   r@   r@   rA   _validate_path  s    z_XMLFrameParser._validate_pathc                 C  s   t | dS )z
        Validate names.

        This method will check if names is a list-like and aligns
        with length of parse nodes.

        Raises
        ------
        ValueError
            * If value is not a list and less then length of nodes.
        NrE   rF   r@   r@   rA   _validate_names  s    z_XMLFrameParser._validate_nameszElement | _Elementraw_docr=   c                 C  s   t | dS )z
        Build tree from path_or_buffer.

        This method will parse XML object into tree
        either from string/bytes or file location.
        NrE   )r?   r   r@   r@   rA   
_parse_doc  s    	z_XMLFrameParser._parse_docN)r   
__module____qualname____doc__rB   rG   rv   r   r   r   r   r@   r@   r@   rA   r$   <   s   S*!
far$   c                   @  sJ   e Zd ZdZddddZddddZddd	d
ZdddddZdS )_EtreeFrameParserz
    Internal class to parse XML into DataFrames with the Python
    standard library XML module: `xml.etree.ElementTree`.
    rC   rD   c                 C  s|   ddl m} | jd urtd| jd u rR| | j| _|   | jj| j	| j
d}|   | jd u rn| |n| |}|S )Nr   r;   zBTo use stylesheet, you need lxml installed and selected as parser.r2   )xml.etree.ElementTreer;   r:   rp   r   r#   xml_docr   rV   r1   r2   r   rv   r   r?   r;   rH   Z	xml_dictsr@   r@   rA   rG     s    

z_EtreeFrameParser.parse_datar0   c              	   C  sx   d}zP| j j| j| jd}|du r*t||durR|ddu rR|jdu rRt|W n ttfyr   tdY n0 dS )z
        Notes
        -----
        `etree` supports limited XPath. If user attempts a more complex
        expression syntax error will raise.
        zxpath does not return any nodes. If document uses namespaces denoted with xmlns, be sure to define namespaces and use them in xpath.r   NrR   zxYou have used an incorrect or unsupported XPath expression for etree library or you used an undeclared namespace prefix.)r   findr1   r2   rp   r`   KeyErrorSyntaxError)r?   msgrH   r@   r@   rA   r     s    	 z _EtreeFrameParser._validate_pathc                 C  s   | j r| jr"| jtt| j }n&| jj| j| jd}|rD|dng }t	| j rnt
| j t
|k rtdntt| j j dd S )Nr   rR   7names does not match length of child elements in xpath. is not a valid type for names)r5   r;   r   r   r   r   r1   r2   rV   r   lenrp   r   r   r   )r?   childrenparentr@   r@   rA   r     s    
z!_EtreeFrameParser._validate_namesr%   r   r   c                 C  sn   ddl m}m} t|| j| j| jd}t|(}|| jd}|||d}W d    n1 s\0    Y  | S )Nr   )	XMLParserparsefilepath_or_bufferr9   r<   r!   r9   parser)	r   r   r   get_data_from_filepathr9   r<   r!   preprocess_datagetroot)r?   r   r   r   handle_dataxml_datacurr_parserr   r@   r@   rA   r     s    
*z_EtreeFrameParser._parse_docN)r   r   r   r   rG   r   r   r   r@   r@   r@   rA   r     s
   r   c                   @  sX   e Zd ZdZddddZddddZddd	d
ZdddddZddddZdS )_LxmlFrameParserz
    Internal class to parse XML into DataFrames with third-party
    full-featured XML library, `lxml`, that supports
    XPath 1.0 and XSLT 1.0.
    rC   rD   c                 C  s   ddl m} | jdu r^| | j| _| jrB| | j| _|  | _|   | jj	| j	| j
d}|   | jdu rz| |n| |}|S )z
        Parse xml data.

        This method will call the other internal methods to
        validate xpath, names, optionally parse and run XSLT,
        and parse original or transformed XML and return specific nodes.
        r   r   Nr   )
lxml.etreer;   r   r#   r   r:   xsl_doc_transform_docr   r1   r2   r   rv   r   r   r@   r@   rA   rG     s    

z_LxmlFrameParser.parse_datar0   c                 C  s|   d}| j j| j| jd}| j j| jd | jd}| j j| jd | jd}|g krXt||g krx|g krx|g krxt|d S )Nzxpath does not return any nodes. Be sure row level nodes are in xpath. If document uses namespaces denoted with xmlns, be sure to define namespaces and use them in xpath.r   z/*z/@*)r   r1   r2   rp   )r?   r   rH   r   attrsr@   r@   rA   r   :  s    z_LxmlFrameParser._validate_pathc                 C  sz   | j rv| jr"| jtt| j }n| jj| jd | jd}t| j r`t| j t|k rvt	dnt
t| j j dd S )Nz[1]/*r   r   r   )r5   r;   r   r   r   r1   r2   r   r   rp   r   r   r   )r?   r   r@   r@   rA   r   N  s    
z _LxmlFrameParser._validate_namesr%   r   r   c           	      C  s   ddl m}m}m} t|| j| j| jd}t|`}|| jd}t	|t
jrx| jd u r^td|| | j|d}n|||d}W d    n1 s0    Y  |S )Nr   )r   
fromstringr   r   r   z2Can not pass encoding None when input is StringIO.r   )r   r   r   r   r   r9   r<   r!   r   r   ioStringIOr   getvalueencode)	r?   r   r   r   r   r   r   r   r   r@   r@   rA   r   c  s&    

*z_LxmlFrameParser._parse_docr   c                 C  s$   ddl m} || j}|| j}|S )z
        Transform original tree using stylesheet.

        This method will transform original xml using XSLT script into
        am ideally flatter xml document for easier parsing and migration
        to Data Frame.
        r   )XSLT)r   r   r   r   )r?   r   transformerZnew_docr@   r@   rA   r     s    

z_LxmlFrameParser._transform_docN)	r   r   r   r   rG   r   r   r   r   r@   r@   r@   rA   r     s   !r   z6FilePath | bytes | ReadBuffer[bytes] | ReadBuffer[str]r-   r   r   z1str | bytes | ReadBuffer[bytes] | ReadBuffer[str])r   r9   r<   r!   r=   c                 C  s   t | tst| } t | tr| dst | trHt| sHt| sHt| rt| d|||d,}t	|j
drr|j
 n|j
} W d   n1 s0    Y  | S )aG  
    Extract raw XML data.

    The method accepts three input types:
        1. filepath (string-like)
        2. file-like object (e.g. open file object, StringIO)
        3. XML string or bytes

    This method turns (1) into (2) to simplify the rest of the processing.
    It returns input types (2) and (3) unchanged.
    rx   r)r9   r<   r!   readN)r   bytesr   r&   r   r   r   r   r   r   handler   )r   r9   r<   r!   Z
handle_objr@   r@   rA   r     s6    
	
 	r   zio.StringIO | io.BytesIOrD   c                 C  s.   t | trt| } nt | tr*t| } | S )z
    Convert extracted raw data.

    This method will return underlying data of extracted XML content.
    The data either has a `read` attribute (e.g. a file object or a
    StringIO/BytesIO) or is a string or bytes that is an XML document.
    )r   r&   r   r   r   BytesIO)datar@   r@   rA   r     s
    	


r   r    c                 K  s|   t t| }dd | D }zBt|fd|i|}| W  d   W S 1 sP0    Y  W n tyv   tdY n0 dS )z
    Convert parsed data to Data Frame.

    This method will bind xml dictionary data of keys and values
    into named columns of Data Frame using the built-in TextParser
    class that build Data Frame and infers specific dtypes.
    c                 S  s   g | ]}t | qS r@   )rq   ro   re   r@   r@   rA   rY     r_   z"_data_to_frame.<locals>.<listcomp>r5   NzqXML document may be too complex for import. Try to flatten document and use distinct element and attribute names.)r   r   r   r   r   )r   kwargstagsnodestpr@   r@   rA   _data_to_frame  s    	,r   r%   r&   r'   r(   r)   r*   r+   r,   r   r.   r/   )r#   r1   r2   r3   r4   r5   r6   r7   r8   r9   r   r:   r;   r<   r!   r=   c                 K  s   |
dkrJt ddd}|dur@t| |||||||||	||||}q~tdn4|
dkrvt| |||||||||	||||}ntd| }tf ||||d	|S )
a  
    Call internal parsers.

    This method will conditionally call internal parsers:
    LxmlFrameParser and/or EtreeParser.

    Raises
    ------
    ImportError
        * If lxml is not installed if selected as parser.

    ValueError
        * If parser is not lxml or etree.
    lxmlz
lxml.etreeignore)errorsNz7lxml not found, please install or use the etree parser.etreez,Values for parser can only be lxml or etree.)r   r6   r7   r8   )r   r   ImportErrorr   rp   rG   r   )r#   r1   r2   r3   r4   r5   r6   r7   r8   r9   r   r:   r;   r<   r!   r   r   pZ
data_dictsr@   r@   rA   _parse  s^    #
r   )versionallowed_args./*Futf-8r   rz   c                 C  s&   t | |||||||||	|
||||dS )a   
    Read XML document into a ``DataFrame`` object.

    .. versionadded:: 1.3.0

    Parameters
    ----------
    path_or_buffer : str, path object, or file-like object
        String, path object (implementing ``os.PathLike[str]``), or file-like
        object implementing a ``read()`` function. The string can be any valid XML
        string or a path. The string can further be a URL. Valid URL schemes
        include http, ftp, s3, and file.

    xpath : str, optional, default './\*'
        The XPath to parse required set of nodes for migration to DataFrame.
        XPath should return a collection of elements and not a single
        element. Note: The ``etree`` parser supports limited XPath
        expressions. For more complex XPath, use ``lxml`` which requires
        installation.

    namespaces : dict, optional
        The namespaces defined in XML document as dicts with key being
        namespace prefix and value the URI. There is no need to include all
        namespaces in XML, only the ones used in ``xpath`` expression.
        Note: if XML document uses default namespace denoted as
        `xmlns='<URI>'` without a prefix, you must assign any temporary
        namespace prefix such as 'doc' to the URI in order to parse
        underlying nodes and/or attributes. For example, ::

            namespaces = {{"doc": "https://example.com"}}

    elems_only : bool, optional, default False
        Parse only the child elements at the specified ``xpath``. By default,
        all child elements and non-empty text nodes are returned.

    attrs_only :  bool, optional, default False
        Parse only the attributes at the specified ``xpath``.
        By default, all attributes are returned.

    names :  list-like, optional
        Column names for DataFrame of parsed XML data. Use this parameter to
        rename original element names and distinguish same named elements and
        attributes.

    dtype : Type name or dict of column -> type, optional
        Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32,
        'c': 'Int64'}}
        Use `str` or `object` together with suitable `na_values` settings
        to preserve and not interpret dtype.
        If converters are specified, they will be applied INSTEAD
        of dtype conversion.

        .. versionadded:: 1.5.0

    converters : dict, optional
        Dict of functions for converting values in certain columns. Keys can either
        be integers or column labels.

        .. versionadded:: 1.5.0

    parse_dates : bool or list of int or names or list of lists or dict, default False
        Identifiers to parse index or columns to datetime. The behavior is as follows:

        * boolean. If True -> try parsing the index.
        * list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3
          each as a separate date column.
        * list of lists. e.g.  If [[1, 3]] -> combine columns 1 and 3 and parse as
          a single date column.
        * dict, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call
          result 'foo'

        .. versionadded:: 1.5.0

    encoding : str, optional, default 'utf-8'
        Encoding of XML document.

    parser : {{'lxml','etree'}}, default 'lxml'
        Parser module to use for retrieval of data. Only 'lxml' and
        'etree' are supported. With 'lxml' more complex XPath searches
        and ability to use XSLT stylesheet are supported.

    stylesheet : str, path object or file-like object
        A URL, file-like object, or a raw string containing an XSLT script.
        This stylesheet should flatten complex, deeply nested XML documents
        for easier parsing. To use this feature you must have ``lxml`` module
        installed and specify 'lxml' as ``parser``. The ``xpath`` must
        reference nodes of transformed XML document generated after XSLT
        transformation and not the original XML document. Only XSLT 1.0
        scripts and not later versions is currently supported.

    iterparse : dict, optional
        The nodes or attributes to retrieve in iterparsing of XML document
        as a dict with key being the name of repeating element and value being
        list of elements or attribute names that are descendants of the repeated
        element. Note: If this option is used, it will replace ``xpath`` parsing
        and unlike xpath, descendants do not need to relate to each other but can
        exist any where in document under the repeating element. This memory-
        efficient method should be used for very large XML files (500MB, 1GB, or 5GB+).
        For example, ::

            iterparse = {{"row_element": ["child_elem", "attr", "grandchild_elem"]}}

        .. versionadded:: 1.5.0

    {decompression_options}

        .. versionchanged:: 1.4.0 Zstandard support.

    {storage_options}

    Returns
    -------
    df
        A DataFrame.

    See Also
    --------
    read_json : Convert a JSON string to pandas object.
    read_html : Read HTML tables into a list of DataFrame objects.

    Notes
    -----
    This method is best designed to import shallow XML documents in
    following format which is the ideal fit for the two-dimensions of a
    ``DataFrame`` (row by column). ::

            <root>
                <row>
                  <column1>data</column1>
                  <column2>data</column2>
                  <column3>data</column3>
                  ...
               </row>
               <row>
                  ...
               </row>
               ...
            </root>

    As a file format, XML documents can be designed any way including
    layout of elements and attributes as long as it conforms to W3C
    specifications. Therefore, this method is a convenience handler for
    a specific flatter design and not all possible XML structures.

    However, for more complex XML documents, ``stylesheet`` allows you to
    temporarily redesign original document with XSLT (a special purpose
    language) for a flatter version for migration to a DataFrame.

    This function will *always* return a single :class:`DataFrame` or raise
    exceptions due to issues with XML document, ``xpath``, or other
    parameters.

    See the :ref:`read_xml documentation in the IO section of the docs
    <io.read_xml>` for more information in using this method to parse XML
    files to DataFrames.

    Examples
    --------
    >>> xml = '''<?xml version='1.0' encoding='utf-8'?>
    ... <data xmlns="http://example.com">
    ...  <row>
    ...    <shape>square</shape>
    ...    <degrees>360</degrees>
    ...    <sides>4.0</sides>
    ...  </row>
    ...  <row>
    ...    <shape>circle</shape>
    ...    <degrees>360</degrees>
    ...    <sides/>
    ...  </row>
    ...  <row>
    ...    <shape>triangle</shape>
    ...    <degrees>180</degrees>
    ...    <sides>3.0</sides>
    ...  </row>
    ... </data>'''

    >>> df = pd.read_xml(xml)
    >>> df
          shape  degrees  sides
    0    square      360    4.0
    1    circle      360    NaN
    2  triangle      180    3.0

    >>> xml = '''<?xml version='1.0' encoding='utf-8'?>
    ... <data>
    ...   <row shape="square" degrees="360" sides="4.0"/>
    ...   <row shape="circle" degrees="360"/>
    ...   <row shape="triangle" degrees="180" sides="3.0"/>
    ... </data>'''

    >>> df = pd.read_xml(xml, xpath=".//row")
    >>> df
          shape  degrees  sides
    0    square      360    4.0
    1    circle      360    NaN
    2  triangle      180    3.0

    >>> xml = '''<?xml version='1.0' encoding='utf-8'?>
    ... <doc:data xmlns:doc="https://example.com">
    ...   <doc:row>
    ...     <doc:shape>square</doc:shape>
    ...     <doc:degrees>360</doc:degrees>
    ...     <doc:sides>4.0</doc:sides>
    ...   </doc:row>
    ...   <doc:row>
    ...     <doc:shape>circle</doc:shape>
    ...     <doc:degrees>360</doc:degrees>
    ...     <doc:sides/>
    ...   </doc:row>
    ...   <doc:row>
    ...     <doc:shape>triangle</doc:shape>
    ...     <doc:degrees>180</doc:degrees>
    ...     <doc:sides>3.0</doc:sides>
    ...   </doc:row>
    ... </doc:data>'''

    >>> df = pd.read_xml(xml,
    ...                  xpath="//doc:row",
    ...                  namespaces={{"doc": "https://example.com"}})
    >>> df
          shape  degrees  sides
    0    square      360    4.0
    1    circle      360    NaN
    2  triangle      180    3.0
    r#   r1   r2   r3   r4   r5   r6   r7   r8   r9   r   r:   r;   r<   r!   )r   r   r@   r@   rA   read_xmlF  s$     {r   )r   NFFNNNNr   r   NNrz   N)6r   
__future__r   r   typingr   r   r   pandas._typingr   r   r   r	   r
   r   r   r   r   pandas.compat._optionalr   pandas.errorsr   r   pandas.util._decoratorsr   r   pandas.core.dtypes.commonr   pandas.core.shared_docsr   pandas.io.commonr   r   r   r   r   r   pandas.io.parsersr   r   r   r   r   r   pandasr    r$   r   r   r   r   r   r   r   r@   r@   r@   rA   <module>   s`   , 
  sd0,Y
              