Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/XML-DOM-serialization/C-sharp/xml-dom-serialization.cs
Normal file
16
Task/XML-DOM-serialization/C-sharp/xml-dom-serialization.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
[XmlRoot("root")]
|
||||
public class ExampleXML
|
||||
{
|
||||
[XmlElement("element")]
|
||||
public string element = "Some text here";
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var xmlnamespace = new XmlSerializerNamespaces();
|
||||
xmlnamespace.Add("", ""); //used to stop default namespaces from printing
|
||||
var writer = XmlWriter.Create("output.xml");
|
||||
new XmlSerializer(typeof(ExampleXML)).Serialize(writer, new ExampleXML(), xmlnamespace);
|
||||
}
|
||||
//Output: <?xml version="1.0" encoding="utf-8"?><root><element>Some text here</element></root>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue