Skip to content

Instantly share code, notes, and snippets.

@Olwaro
Last active December 19, 2015 12:48
Show Gist options
  • Save Olwaro/5956964 to your computer and use it in GitHub Desktop.
Save Olwaro/5956964 to your computer and use it in GitHub Desktop.
Create xml file with .NET XDocument
XDocument xdoc =
new XDocument(
new XElement("format",
new XElement("separateur", separateur), // simple tag
new XElement("delimiteur", delimiteur),
new XElement("skip", skipEntete ? "1" : "0"),
new XElement("colones", // foreach items in list 'choix' : return a tag with some attributes
choix.Select(ci => new XElement("col", new XAttribute("ordre", choix.IndexOf(ci)), new XAttribute("champ", ci.Identifiant)))
)
)
);
File.WriteAllText("path", xdoc.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment