Here is a XML with various values as follows. How can I parse each value?
df = pd.read_xml(StringIO(r.text), xpath='//*[local-name()="result"]')
This shows: RGT_STD_DT CASH_ALOC_RATIO ISSUCO_CUSTNO RGT_RACD 0 NaN NaN NaN NaN 1 NaN NaN
NaN NaN 2 NaN NaN NaN NaN 3
NaN NaN NaN NaN 4 NaN NaN
NaN NaN 5 NaN NaN NaN NaN 6
NaN NaN NaN NaN 7 NaN NaN
NaN NaN 8 NaN NaN NaN NaN 9
NaN NaN NaN NaN
<?xml version="1.0" encoding="UTF-8"?>
<vector result="10">
<data vectorkey="0" type="Document">
<result>
<RGT_STD_DT value="20231005"/>
<CASH_ALOC_RATIO value="220"/>
<ISSUCO_CUSTNO value="997"/>
<RGT_RACD value="103"/>
</result>
</data>
</vector>
Could you please hele me to get each value under "result"?
Values are stored in attributes not on element's text.
For the given sample: read all attributes, transpose the frame, and give each column the element name
Transposed frame
Final result with column names
if more that 1 result element is present use
Result
Using Pandas 2.1.1
This version has much better handling of NaNs or NaTs
Result NaN now appears as NaT since dates are parsed.
value=""
would produce a NaT