Skip to content

Getting Text and Attributes from Child Element #287

@allRisc

Description

@allRisc

It would be nice in some situations to have the ability to get the text value of a child element in one model field and get a dictionary of the element's attributes in another model field such as below:

class Range(BaseXmlModel, ns="ipxact", tag="range", nsmap=NSMAP):

    left: int = element("left")
    right: int = element("right")
    left_attribs: Dict[str, str] = element(tag="left", default_factory=dict)
    right_attribs: Dict[str, str] = element(tag="right", default_factory=dict)

with an XML Example of:

<range>
    <left minimum="0">0</left>
    <right minimum="8">15</right>
</range>

Currently this results in left_attribs and right_attribs being empty dictionaries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions