1

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>
5
  • 3
    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. Commented Aug 29, 2018 at 18:58
  • 2
    As @PhonicUK said - take a look at Xml Serialization Commented Aug 29, 2018 at 19:00
  • @PhonicUK can you put that as an answer? Commented Aug 29, 2018 at 19:16
  • @Hatsumi all done :) Commented Aug 29, 2018 at 21:03
  • Neither of the two xml files posted are well formed and you may have issue using standard Net Library method to create the files as posted. An xml file has only one element at the root level. Both of the xml posted have an array of elements at the root. Commented Aug 29, 2018 at 21:13

1 Answer 1

1

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#.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.