Hatsumi
Hatsumi

Reputation: 2228

How to create a XML file dynamically?

The problem that I want to solve is that I need to create many XML files.

I know what tags are in which type of XML (examples of XML below) and I know a list of a possible data that could be in each tag.

Someone knows a good way to make that?

I can have XML like the examples below:

XML1:

<ID>1</ID>
<name>Maria</name>
<type>client</type>
    <addresses>
        <address>
            <street>Brooklin</street>
            <number>123</number>
        <address>
        <address>
            <street>New York Street</street>
            <number>1000</number>
        <address>
    </addresses>

XML2:

<name>Paulo</name>
<age>26</age>
<subject>complain</subject>
    <addresses>
        <address>
            <street>Brooklin</street>
            <number>123</number>
        <address>
    </addresses>

Upvotes: 1

Views: 4256

Answers (1)

PhonicUK
PhonicUK

Reputation: 13864

The magic word you're looking for is Serialization. You want to have a data structure that matches the XML you want to produce and serialize it to XML.

Here's some documentation on doing this in C#.

Upvotes: 1

Related Questions