Are they a good way to generate an XML file through C # in .NET.

I want to make an xml file like:

<?xml version="1.0" encoding="Windows-1252" ?>
<settings>
    <typeofsetting>
        <wordname="add" />
    </typeofsettings>
</settings>

wordnamemay depend on what the user needs. How can I create an application that the user can create an XML file of what they need. Is there a good way to do this?

wordname not the user determined that he came from a database that was embedded in the application.

Do they have good practice doing this in C # win-form?

+3
source share
2 answers
using System.Xml.Linq;

...

public void Foo()
{
    var doc = new XDocument(
        new XDeclaration("1.0", "Windows-1252", "yes"),
        new XElement("settings",
            new XElement("typeofsetting",
                new XElement("word", new XAttribute("name", "add")))));
    doc.Save("SomeFile.xml");
}

You can tailor this example to suit your needs.

+6
source

Yes

use LINQ TO XML

one of the easiest ways to create xml

+4
source

Source: https://habr.com/ru/post/1784025/


All Articles