I would suggest to use: 1)
XDocument class[
^] or 2)
XML Serialization[
^].
Ad 1)
XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8",""));
XElement xroot = new XElement("root");
xroot.Add(
new XElement("Lgd", new XAttribute("QdsName", "Ldg:BOTTOM_PLANE"),
new XElement("Field", new XAttribute("Dsc","Z1"), new XAttribute("T", "Double"), "Value"),
new XElement("Field", new XAttribute("Dsc","BaseDia"), new XAttribute("T", "Double"), "Value")),
new XElement("Lgd", new XAttribute("QdsName", "Ldg:TOP_PLANE_TOTAL_WIDTH"),
new XElement("Field", new XAttribute("Dsc","Z2"), new XAttribute("T", "Double"), "Value"),
new XElement("Field", new XAttribute("Dsc","FF_Dia"), new XAttribute("T", "Double"), "Value")),
new XElement("Lgd", new XAttribute("QdsName", "Ldg:BORE_BOTTOM_SIDE"),
new XElement("Field", new XAttribute("Dsc","Z3"), new XAttribute("T", "Double"), "Value"),
new XElement("Field", new XAttribute("Dsc","BORE_DIA_1"), new XAttribute("T", "Double"), "Value"))
);
xdoc.Add(xroot);
Ad 2)
XML Serialization and Deserialization: Part-1[
^]
XML Serialization and Deserialization: Part-2[
^]
XML Serialization and Deserialization in C#[
^]