> For the complete documentation index, see [llms.txt](https://23maverick23.gitbook.io/oaxmlapi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://23maverick23.gitbook.io/oaxmlapi/docs/datatypes.md).

# datatypes

## Datatype

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

| **attribute** | **type** | **description**                   |
| ------------- | -------- | --------------------------------- |
| type          | String   | an OpenAir complex type           |
| fields        | Dict     | a dictionary of key\[value] pairs |

### getDatatype

Returns an *ElementTree* object.

```python
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()`.
