1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
U
¬ý°dK•ã@s$dZddlmZddlZddlmZmZmZddlm    Z    ddl
m Z m Z m Z mZmZmZmZmZmZmZddlmZddlmZmZdd    lmZdd
lmZdd lmZdd l m!Z!dd l"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*e r
ddl+m,Z,ddl-m.Z.ddl/m0Z0ee!de!dddGdd„dƒƒZ1Gdd„de1ƒZ2Gdd„de1ƒZ3ddddd d!œd"d#„Z4d$d%œd&d'„Z5d(d%œd)d*„Z6e    j7fd+d,d-d.d.d/d0d1d2dd3d4d5ddd6d(d7œd8d9„Z8ee!de!dddd:dd;d;ddddd<d=ddd>de    j7d?œd+d,d-d.d.d/d0d1d2dd3d4d5ddd6d(d7œd@dA„ƒZ9dS)Bz3
:mod:`pandas.io.xml` is a module for reading XML.
é)Ú annotationsN)ÚAnyÚCallableÚSequence)Úlib)
Ú TYPE_CHECKINGÚCompressionOptionsÚ ConvertersArgÚDtypeArgÚ DtypeBackendÚFilePathÚ ParseDatesArgÚ
ReadBufferÚStorageOptionsÚ
XMLParsers)Úimport_optional_dependency)ÚAbstractMethodErrorÚ ParserError)Údoc)Úcheck_dtype_backend)Ú is_list_like)Ú _shared_docs)Ú file_existsÚ
get_handleÚinfer_compressionÚ is_fsspec_urlÚis_urlÚstringify_path)Ú
TextParser)ÚElement)Úetree)Ú    DataFrameÚstorage_optionsÚdecompression_optionsÚpath_or_buffer)r"r#c@s”eZdZdZddddddddd    d
d d d dddœdd„Zddœdd„Zdddœdd„Zdddœdd„Zddœdd „Zddœd!d"„Z    dd#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 | Noneú5FilePath | ReadBuffer[bytes] | ReadBuffer[str] | Noneúdict[str, list[str]] | NonerrÚNone)r$ÚxpathÚ
namespacesÚ
elems_onlyÚ
attrs_onlyÚnamesÚdtypeÚ
convertersÚ parse_datesÚencodingÚ
stylesheetÚ    iterparseÚ compressionr"ÚreturncCs^||_||_||_||_||_||_||_||_|    |_|
|_    | |_
| |_ d|_ | |_ ||_dS©N)r$r2r3r4r5r6r7r8r9r:r;r<Zis_styler=r")Úselfr$r2r3r4r5r6r7r8r9r:r;r<r=r"©rAúDd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/io/xml.pyÚ__init__‘sz_XMLFrameParser.__init__úlist[dict[str, str | None]]©r>cCs t|ƒ‚dS)zž
        Parse xml data.
 
        This method will call the other internal methods to
        validate xpath, names, parse and return specific nodes.
        N©r©r@rArArBÚ
parse_data²sz_XMLFrameParser.parse_dataú    list[Any])Úelemsr>csֈjrˆjrtdƒ‚ˆjrDˆjr4‡fdd„|Dƒ}q‚dd„|Dƒ}n>ˆjrZdd„|Dƒ}n(ˆjrt‡fdd„|Dƒ}ndd„|Dƒ}dd„|Dƒ}tt d    d„|Dƒ¡ƒ‰‡fd
d„|Dƒ}ˆjr҇fd 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    sLg|]D}|jr(|j ¡s(|j|j ¡inidd„tˆj| d¡ƒDƒ–‘qS)cSs&i|]\}}||jr|j ¡nd“qSr?©ÚtextÚstrip©Ú.0ÚnmÚchrArArBÚ
<dictcomp>Ýsÿú;_XMLFrameParser._parse_nodes.<locals>.<listcomp>.<dictcomp>Ú*)rLÚisspaceÚtagrMÚzipr6Úfindall©rOÚelrGrArBÚ
<listcomp>Ös øÿÿþúz0_XMLFrameParser._parse_nodes.<locals>.<listcomp>cSs g|]}dd„| d¡Dƒ‘qS)cSs$i|]}|j|jr|j ¡nd“qSr?©rVrLrM©rOrQrArArBrRæsÿrSrT©rXrYrArArBr[åsüþcSs g|]}dd„|j ¡Dƒ‘qS)cSs"i|]\}}||r| ¡nd“qSr?)rM©rOÚkÚvrArArBrRïsrS©ÚattribÚitemsrYrArArBr[îsÿc
sPg|]H}|j|jr,|j ¡s,|j|j ¡inidd„tˆj| d¡ƒDƒ–‘qS)cSs&i|]\}}||jr|j ¡nd“qSr?rKrNrArArBrRýsÿrSrT)rcrLrUrVrMrWr6rXrYrGrArBr[õs õÿÿþùcSsHg|]@}|j|jr,|j ¡s,|j|j ¡inidd„| d¡Dƒ–‘qS)cSs$i|]}|j|jr|j ¡nd“qSr?r\r]rArArBrRsÿrSrT)rcrLrUrVrMrXrYrArArBr[s õÿÿþùcSsg|]}dd„| ¡Dƒ‘qS)cSs,i|]$\}}d|kr"| d¡dn||“qS)Ú}é)Úsplitr_rArArBrRsrS)rd©rOÚdrArArBr[scSsg|]}| ¡D]}|‘qqSrA©Úkeys©rOrir`rArArBr[s
csg|]‰‡fdd„ˆDƒ‘qS)cs&i|]}||ˆ ¡krˆ|nd“qSr?rj©rOr`©rirArBrRsrSrA©rOrjrnrBr[scs g|]}ttˆj| ¡ƒƒ‘qSrA©ÚdictrWr6ÚvaluesrhrGrArBr[s)r4r5Ú
ValueErrorr6ÚlistrqÚfromkeys)r@rJÚdictsrA©rkr@rBÚ _parse_nodes¼s: 
ôûþ
ó óÿz_XMLFrameParser._parse_nodesr)r<r>c sìg}d}tˆjtƒs*ttˆjƒj›dƒ‚ˆjrBttˆj ¡ƒƒnd}t    ˆj|ƒslttˆj|ƒ›dƒ‚t
ˆj dƒs¼tˆj t ƒr´t ˆj ƒs´tˆj ƒs´ˆj  d¡s´tˆj dƒdk    r¼tdƒ‚tˆj|ƒttˆj|ƒƒk}|ˆj d    d
D]¤\}}d |jkr|j d ¡d n|j}|d kr.||kr.i}|dk    r.ˆjrÞ|rÞtˆj|ˆjƒD]‚\}    }
||    kr |jr||j ¡nd} | | ¡kr |
|kr | ||
<|    |jkrX|j|    | ¡krX|
|krX|j|    ||
<qXnPˆj|D]D}    ||    kr|jr|j ¡nd||    <|    |jkrè|j|    ||    <qè|dkrê||krX|dk    rX| |¡d}| ¡t
|dƒrê| ¡dk    rê| ¡dk    rê| ¡d=qjqê|gkr¤tdƒ‚t t !dd„|Dƒ¡ƒ‰‡fdd„|Dƒ}ˆjrè‡fdd„|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 file on disk or file-like object.
            * 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Úread©z<?xmlú<Úinferziterparse is designed for large XML files that are fully extracted on local disk and not as compressed files or online sources.)ÚstartÚend)Úeventsrerfr~rÚ getpreviousrz+No result from selected items in iterparse.cSsg|]}| ¡D]}|‘qqSrArjrlrArArBr[€s
z4_XMLFrameParser._iterparse_nodes.<locals>.<listcomp>csg|]‰‡fdd„ˆDƒ‘qS)cs&i|]}||ˆ ¡krˆ|nd“qSr?rjrmrnrArBrRsz?_XMLFrameParser._iterparse_nodes.<locals>.<listcomp>.<dictcomp>rArorjrnrBr[scs g|]}ttˆj| ¡ƒƒ‘qSrArprhrGrArBr[„s)"Ú
isinstancer<rqÚ    TypeErrorÚtypeÚ__name__ÚnextÚiterrkrÚhasattrr$r'rrÚ
startswithrrÚlenÚsetrVrgr6rWrLrMrrrcÚappendÚclearrZ    getparentrtru) r@r<rvÚrowZrow_nodeZiterparse_repeatsÚeventÚelemZ    curr_elemÚcolrPZelem_valrArwrBÚ_iterparse_nodes"s„ ÿÿ 
ÿþý
üûÿ ÿ"
 
 
 
 
 
 
 
ÿ
ÿ
z _XMLFrameParser._iterparse_nodescCs t|ƒ‚dS)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.
        NrFrGrArArBÚ_validate_pathˆsz_XMLFrameParser._validate_pathcCs t|ƒ‚dS)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.
        NrFrGrArArBÚ_validate_names™s z_XMLFrameParser._validate_nameszElement | etree._Element©Úraw_docr>cCs t|ƒ‚dS)z™
        Build tree from path_or_buffer.
 
        This method will parse XML object into tree
        either from string/bytes or file location.
        NrF)r@r–rArArBÚ
_parse_doc§s    z_XMLFrameParser._parse_docN) r…Ú
__module__Ú __qualname__Ú__doc__rCrHrxr’r“r”r—rArArArBr%9sS*!
ffr%c@sJeZdZdZddœdd„Zddœdd„Zd    dœd
d „Zd d dœdd„ZdS)Ú_EtreeFrameParserz
    Internal class to parse XML into DataFrames with the Python
    standard library XML module: `xml.etree.ElementTree`.
    rDrEcCshddlm}|jdk    rtdƒ‚|jdkr>| |j¡|_| ¡}| ¡|jdkrZ|     |¡n| 
|¡}|S)Nr©r<zBTo use stylesheet, you need lxml installed and selected as parser.) Úxml.etree.ElementTreer<r;rsr—r$Úxml_docr“r”rxr’©r@r<rJZ    xml_dictsrArArBrH¹s 
ÿ
ÿ ýz_EtreeFrameParser.parse_datarIc    Csºd}z|jj|j|jd}dd„|Dƒ}dd„|Dƒ}|dkrFt|ƒ‚|dk    r’|jrd|gkrdt|ƒ‚|jrz|ikrzt|ƒ‚|gkr’|ikr’t|ƒ‚Wn ttfk
r´tdƒ‚YnX|S)    z™
        Notes
        -----
        `etree` supports limited XPath. If user attempts a more complex
        expression syntax error will raise.
        úæxpath does not return any nodes or attributes. Be sure to specify in `xpath` the parent nodes of children and attributes to parse. If document uses namespaces denoted with xmlns, be sure to define namespaces and use them in xpath.©r3cSs g|]}| d¡D]}|‘qqS©rTr^©rOrZrQrArArBr[ás z4_EtreeFrameParser._validate_path.<locals>.<listcomp>cSs&i|]}|j ¡D]\}}||“qqSrArb©rOrZr`rarArArBrRâs
 z4_EtreeFrameParser._validate_path.<locals>.<dictcomp>NzxYou have used an incorrect or unsupported XPath expression for etree library or you used an undeclared namespace prefix.)    ržrXr2r3rsr4r5ÚKeyErrorÚ SyntaxError©r@ÚmsgrJÚchildrenÚattrsrArArBr“Ïs(    ÿ ÿ
z _EtreeFrameParser._validate_pathr1cCsˆ|jr„|jr"|jtt|jƒƒ}n&|jj|j|jd}|rD| d¡ng}t    |jƒrnt
|jƒt
|ƒkr„t dƒ‚nt t |jƒj›dƒ‚dS)Nr¡rTú7names does not match length of child elements in xpath.ú is not a valid type for names)r6r<r†r‡ržÚfindr2r3rXrrŠrsrƒr„r…)r@r©ÚparentrArArBr”øs
ÿÿz!_EtreeFrameParser._validate_namesr&rr•c    CsZddlm}m}t||j|j|jd}t|ƒ}||jd}|||d}W5QRX| ¡S)Nr)Ú    XMLParserÚparse©Úfilepath_or_bufferr:r=r"©r:©Úparser)    rr¯r°Úget_data_from_filepathr:r=r"Úpreprocess_dataÚgetroot)r@r–r¯r°Ú handle_dataÚxml_dataÚ curr_parserÚdocumentrArArBr— sü
 z_EtreeFrameParser._parse_docN)r…r˜r™ršrHr“r”r—rArArArBr›³s
)r›c@sXeZdZdZddœdd„Zddœdd„Zd    dœd
d „Zd d dœdd„Zddœdd„ZdS)Ú_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.
    rDrEcCstddlm}|jdkrJ| |j¡|_|jrB| |j¡|_| ¡|_| ¡}|     ¡|jdkrf| 
|¡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.
        rrœN) Ú
lxml.etreer<r—r$ržr;Úxsl_docÚ_transform_docr“r”rxr’rŸrArArBrH)s 
 
ÿ ýz_LxmlFrameParser.parse_datarIcCs”d}|jj|j|jd}dd„|Dƒ}dd„|Dƒ}|gkrDt|ƒ‚|gkr|jrb|gkrbt|ƒ‚|jrx|ikrxt|ƒ‚|gkr|ikrt|ƒ‚|S)Nr r¡cSs g|]}| d¡D]}|‘qqSr¢)r2r£rArArBr[Qs z3_LxmlFrameParser._validate_path.<locals>.<listcomp>cSs&i|]}|j ¡D]\}}||“qqSrArbr¤rArArBrRRs
 z3_LxmlFrameParser._validate_path.<locals>.<dictcomp>)ržr2r3rsr4r5r§rArArBr“Fsÿ    z_LxmlFrameParser._validate_pathr1cCsz|jrv|jr"|jtt|jƒƒ}n|jj|jd|jd}t|jƒr`t|jƒt|ƒkrvt    dƒ‚nt
t |jƒj ›dƒ‚dS)Nz[1]/*r¡r«r¬) r6r<r†r‡ržr2r3rrŠrsrƒr„r…)r@r©rArArBr”asÿ
ÿÿz _LxmlFrameParser._validate_namesr&zetree._Elementr•c        Cs’ddlm}m}m}t||j|j|jd}t|ƒV}||jd}t    |t
j ƒrx|jdkr^t dƒ‚||  ¡ |j¡|d}n |||d}W5QRX|S)Nr)r¯Ú
fromstringr°r±r³z2Can not pass encoding None when input is StringIO.r´)r¾r¯rÁr°r¶r:r=r"r·r‚ÚioÚStringIOrƒÚgetvalueÚencode)    r@r–r¯rÁr°r¹rºr»r¼rArArBr—vs(ü
 
ÿÿz_LxmlFrameParser._parse_doczetree._XSLTResultTreecCs$ddlm}||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ÆZ transformerZnew_docrArArBrÀ—s 
 
z_LxmlFrameParser._transform_docN)    r…r˜r™ršrHr“r”r—rÀrArArArBr½"s !r½z6FilePath | bytes | ReadBuffer[bytes] | ReadBuffer[str]r.rrz1str | bytes | ReadBuffer[bytes] | ReadBuffer[str])r²r:r=r"r>c    Cs†t|tƒst|ƒ}t|tƒr‚| d¡s‚t|tƒrHt|ƒsHt|ƒsHt|ƒr‚t|d|||d"}t    |j
dƒrr|j
  ¡n|j
}W5QRX|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.
    r{Úr)r:r=r"rz) r‚Úbytesrr'r‰rrrrrˆÚhandlerz)r²r:r=r"Z
handle_objrArArBr¶§s6
ÿþüûúù    û
ÿ ý r¶zio.StringIO | io.BytesIOrEcCs.t|tƒrt |¡}nt|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)ÚdatarArArBr·Ôs
    
 
 
r·r!c
Ksrtt|ƒƒ}dd„|Dƒ}z6t|fd|i|—Ž}| ¡W5QR£WSQRXWntk
rltdƒ‚YnXdS)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.
    cSsg|]}t| ¡ƒ‘qSrA)rtrrrhrArArBr[ðsz"_data_to_frame.<locals>.<listcomp>r6zqXML document may be too complex for import. Try to flatten document and use distinct element and attribute names.N)r†r‡rrzr)rËÚkwargsÚtagsZnodesÚtprArArBÚ_data_to_frameæs      ÿrÏr&r'r(r)r*r+r,r-rr/r0zDtypeBackend | lib.NoDefault)r$r2r3r4r5r6r7r8r9r:rµr;r<r=r"Ú dtype_backendr>cKs |
dkrJtddd}|dk    r@t||||||||||    | | | |ƒ}q~tdƒ‚n4|
dkrvt||||||||||    | | | |ƒ}ntdƒ‚| ¡}tf|||||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.r z,Values for parser can only be lxml or etree.)rËr7r8r9rÐ)rr½Ú ImportErrorr›rsrHrÏ)r$r2r3r4r5r6r7r8r9r:rµr;r<r=r"rÐrÌrÑÚpZ
data_dictsrArArBÚ_parseýs`$ ò
òûúrÖz./*Fzutf-8rÑr})r2r3r4r5r6r7r8r9r:rµr;r<r=r"rÐcCs0t|ƒ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}
 
    dtype_backend : {{"numpy_nullable", "pyarrow"}}, defaults to NumPy backed DataFrames
        Which dtype_backend to use, e.g. whether a DataFrame should have NumPy
        arrays, nullable dtypes are used for all dtypes that have a nullable
        implementation when "numpy_nullable" is set, pyarrow is used for all
        dtypes if "pyarrow" is set.
 
        The dtype_backends are still experimential.
 
        .. versionadded:: 2.0
 
    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$r2r3r4r5r6r7r8r9r:rµr;r<r=r"rÐ)rrÖr×rArArBÚread_xmlXs*ðrØ):ršÚ
__future__rrÂÚtypingrrrZ pandas._libsrZpandas._typingrrr    r
r r r rrrZpandas.compat._optionalrZ pandas.errorsrrZpandas.util._decoratorsrZpandas.util._validatorsrZpandas.core.dtypes.commonrZpandas.core.shared_docsrZpandas.io.commonrrrrrrZpandas.io.parsersrrrrÑr Zpandasr!r%r›r½r¶r·rÏZ
no_defaultrÖrØrArArArBÚ<module>sh  0          
þxo-'ð0[
þî