I want to create xml document with following structure
<ServerFp Command="Cashed">
<Cashed Value="199.99"/>
</ServerFp>
So I tried like this :
XmlWriterSettings settings = new XmlWriterSettings() { Indent = true };
using (var writer = XmlWriter.Create(filename, settings))
{
writer.WriteStartDocument();
writer.WriteStartElement("ServerFp");
writer.WriteAttributeString("Command", "Cashed");
}
Is this good so far and how to end this file? with node <Cashed Value="199.99"/>
I would try doing it like this:
create a new XmlDocument:
XmlDocument doc = new XmlDocument();
create your nodes you want to insert
XmlNode node1 = doc.CreateElement("node1")
append your element
doc.AppendChild(node1 );
save the document
doc.Save("result.xml");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With