Jun-19-2019, 07:43 AM
I'm trying to parse data from an XML file downloaded from https://scsanctions.un.org/resources/xml...idated.xml
Sample of the XML file is attached.
<?xml version="1.0" encoding="UTF-8"?>
<CONSOLIDATED_LIST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.un.org/sc/resources/sc-sanctions.xsd" dateGenerated="2019-06-17T19:04:28.013-04:00">
I tried to parse the value for "dateGenerated" metadata, but it was not successful.
Appreciate if some can help on this.
Sample of the XML file is attached.
<?xml version="1.0" encoding="UTF-8"?>
<CONSOLIDATED_LIST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.un.org/sc/resources/sc-sanctions.xsd" dateGenerated="2019-06-17T19:04:28.013-04:00">
I tried to parse the value for "dateGenerated" metadata, but it was not successful.
Appreciate if some can help on this.
import pandas as pd
import xml.etree.ElementTree as ET
file1 = ET.parse(r'scsanctions.un.org_copy.xml')
for node in file1.getroot():
print(ET.tostring(node, encoding='utf8').decode('utf8'))
print(node)
for i in node:
dataid= [dataid.text for dataid in i.findall('DATAID')]
print(dataid)
# Try 1
d = node.findall('dateGenerated')
print(d.text)
d1= file1.findall('dateGenerated')
print(d1)
Attached Files
