dapper91 / pydantic-xml

python xml for humans
https://pydantic-xml.readthedocs.io
The Unlicense
141 stars 14 forks source link

Why does one of the attributes become the sub text of this element? #155

Closed mcleantom closed 6 months ago

mcleantom commented 6 months ago

I have a model like:

class ScheduleElement(BaseXmlModel, tag="scheduleElement"):
    waypointId: types.xsd.nonNegativeInteger = attr(default=None, description="Unique waypoint identifier.")
    etd: Optional[types.ISO8601] = attr(default=None, description="UTC estimated departure time in ISO 8601 format.")

and I am serializing it to xml and it outputs:

<scheduleElement etd="2020-02-28T00:00:00Z">11</scheduleElement>

When I would expect it to output like:

<scheduleElement etd="2020-02-28T00:00:00Z" waypointId="11"/>

Why is this and how do I fix it?

Thanks