Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created January 27, 2018 02:57
Escribir un archivo XML con Python.
import xml.etree.ElementTree as ET
elemento_1 = ET.Element('SistemasOperativos')
elemento_hijo_1 = ET.SubElement(elemento_1, 'Windows')
elemento_hijo_2 = ET.SubElement(elemento_1, 'Linux')
elemento_hijo_3 = ET.SubElement(elemento_1, 'MacOS')
archivo = open('SistemasOperativos.xml', 'a')
archivo.write(ET.tostring(elemento_1, encoding='utf-8').decode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment