using System.Collections.Generic;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO.Compression;
public static void Test()
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(GetXml());
Console.WriteLine("\nInitial XML:");
Console.WriteLine(xmlDoc.GetOuterXml());
var namespaceURI = xmlDoc.DocumentElement.NamespaceURI;
var subsystem = xmlDoc.DocumentElement.AppendChild(xmlDoc.CreateElement("subsystem", namespaceURI));
subsystem.Attributes.Append(xmlDoc.CreateAttributeWithValue("name", "hahaha"));
subsystem.Attributes.Append(xmlDoc.CreateAttributeWithValue("tag1", "NoNo"));
subsystem.Attributes.Append(xmlDoc.CreateAttributeWithValue("tag2", "SoNo"));
Console.WriteLine("\nModified XML:");
Console.WriteLine(xmlDoc.GetOuterXml());
var xml = @"<?xml version=""1.0""?>
<chssystem ExportDate=""2/21/2018"" ExportTime=""2:57 PM EST"" DateFormat=""MM/dd/yyyy"" NumberFormat=""HH:mm:ss "" SchemaValidation=""true"" ExportVersion=""2016.1.SP1710.57"" xmlns=""http://www.mentor.com/harness/Schema/LibrarySchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.mentor.com/harness/Schema/LibrarySchema file:/C:/MentorGraphics/VeSys_Client/dtd/LibrarySchema.xsd"" XMLVersion=""1.6"">
<librarycomponenttype librarycomponenttype_id=""_GROUPID_CONNECTOR"" description=""Connector"" clipgromident="""" typecode=""CONN"" />
<connectorpart libraryobject_id=""_OID_CTEST"" depth=""0.0"" description=""TEST DATA"" graphics=""0"" groupname=""Connector"" librarycomponenttype_id=""_GROUPID_CONNECTOR"" cavityqt=""1"" partnumber=""CONN-C-TEST"" unitofmeasure=""Each"" >
<librarycavity librarycavity_id=""ID1"" ca_mappingtype=""Userdefined"" ca_attach="" "" isblocked=""1"" pingraphic="" "" cavityname=""1"" librarypincontainer_id=""_OID_CTEST"" sortorder=""1""/>
public static class XmlNodeExtensions
public static XmlAttribute CreateAttributeWithValue(this XmlDocument doc, string name, string value)
var attr = doc.CreateAttribute(name);
public static class XmlSerializationHelper
public static string GetOuterXml(this XmlNode node, bool indent = true)
using (var textWriter = new StringWriter())
var settings = new XmlWriterSettings
OmitXmlDeclaration = true,
using (var xmlWriter = XmlWriter.Create(textWriter, settings))
return textWriter.ToString();
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message ?? "failed");
public static void Main()
Console.WriteLine("Roslyn 2.0 Compiler; Environment version: " + Environment.Version);
Console.WriteLine("Uncaught exception: ");