c# - create xml file, basics -
i want create xml document following structure
<serverfp command="cashed"> <cashed value="199.99"/> </serverfp>
so tried :
xmlwritersettings settings = new xmlwritersettings() { indent = true }; using (var writer = xmlwriter.create(filename, settings)) { writer.writestartdocument(); writer.writestartelement("serverfp"); writer.writeattributestring("command", "cashed"); }
is far , how end file? node <cashed value="199.99"/>
why not linq xml?
xelement serverfp = new xelement("serverfp", new xattribute("command", "cached"), new xelement("cachedvalue", "199.99") ); console.writeline(serverfp.tostring());
outputting
<serverfp command="cached"> <cachedvalue>199.99</cachedvalue> </serverfp>
Comments
Post a Comment