datatypes

Datatype

Use the Datatype method to create XML objects using the ElementTree library.

getDatatype

Returns an ElementTree object.

my_date = datatypes.Datatype(
    'Date',
    {
        'month': '03',
        'day': '14',
        'year': '2012',
        'hour': '08',
        'minute': '35',
        'second': '43'
    }
)
print(my_date.tostring())
>>> b'<Date><hour>08</hour><month>03</month><second>43</second><year>2012</year><day>14</day><minute>35</minute></Date>'

print(my_date.prettify())
>>> b'''
<?xml version="1.0" encoding="utf-8"?>
<Date>
  <hour>08</hour>
  <month>03</month>
  <second>43</second>
  <year>2012</year>
  <day>14</day>
  <minute>35</minute>
</Date>
'''

Supports tostring() and prettify().

Last updated