Skip to content

native

xsdata.formats.dataclass.serializers.tree.native

XmlTreeSerializer dataclass

Bases: TreeSerializer

Source code in xsdata/formats/dataclass/serializers/tree/native.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@dataclass
class XmlTreeSerializer(TreeSerializer):
    def render(self, obj: T) -> Element:
        """Serialize the input model instance to element tree.

        Args:
            obj: The input model instance to serialize

        Returns:
            The generated element tree instance.
        """
        builder = TreeBuilder()
        self.build(obj, builder)
        return builder.close()

render(obj)

Serialize the input model instance to element tree.

Parameters:

Name Type Description Default
obj T

The input model instance to serialize

required

Returns:

Type Description
Element

The generated element tree instance.

Source code in xsdata/formats/dataclass/serializers/tree/native.py
10
11
12
13
14
15
16
17
18
19
20
21
def render(self, obj: T) -> Element:
    """Serialize the input model instance to element tree.

    Args:
        obj: The input model instance to serialize

    Returns:
        The generated element tree instance.
    """
    builder = TreeBuilder()
    self.build(obj, builder)
    return builder.close()