Sobes.tech
Junior — Middle

How to represent a list of objects in XML format?

sobes.tech AI

Answer from AI

To represent a list of objects in XML format, you need to create a root element, inside which elements corresponding to each object will be nested. Each object is represented by a tag with a set of nested tags for its fields.

Example of XML for a list of users:

<users>
    <user>
        <id>1</id>
        <name>Ivan</name>
        <email>ivan@example.com</email>
    </user>
    <user>
        <id>2</id>
        <name>Maria</name>
        <email>maria@example.com</email>
    </user>
</users>

In Android, to generate XML, you can use classes like XmlSerializer or third-party libraries that help serialize objects into the required format.