using System.Collections.Generic;
using System.Xml.Serialization;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Globalization;
using System.ComponentModel.DataAnnotations;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
public Section Section { get; set; }
[XmlElement("templateId")]
public List<IdElement> TemplateIds { get; set; }
public CodeElement Code { get; set; }
public string Title { get; set; }
public Text Text { get; set; }
public Table Table { get; set; }
public List<string> List { get; set; }
[XmlElement("paragraph")]
public List<string> Paragraphs { get; set; }
public TablePart Header { get; set; }
public TablePart Body { get; set; }
[XmlElement(ElementName = "tr", Namespace = "")]
public List<TableRow> RowData { get; set; }
public List<string> Data { get; set; }
public List<string> Headers { get; set; }
public static void Test()
var component = xml.LoadFromXml<Component>();
var xml2 = component.GetXml(true);
<templateId root='2.16.840.1.113883.10.20.1.11'/>
<templateId root='1.3.6.1.4.1.19376.1.5.3.1.3.6'/>
<!--<id root='' extension=''/>-->
<code code=""11450-4"" displayName=""PROBLEM LIST"" codeSystem=""2.16.840.1.113883.6.1"" codeSystemName=""LOINC""/>
<title>Active Problem - Problem List</title>
<td>Costal chondritis</td>
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 class XmlSerializationHelper
public static T LoadFromXml<T>(this string xmlString, XmlSerializer serial = null)
serial = serial ?? new XmlSerializer(typeof(T));
T returnValue = default(T);
using (StringReader reader = new StringReader(xmlString))
object result = serial.Deserialize(reader);
public static string GetXml<T>(this T obj, bool omitStandardNamespaces)
return obj.GetXml(null, omitStandardNamespaces);
public static string GetXml<T>(this T obj, XmlSerializer serializer = null, bool omitStandardNamespaces = false)
XmlSerializerNamespaces ns = null;
if (omitStandardNamespaces)
ns = new XmlSerializerNamespaces();
using (var textWriter = new StringWriter())
var settings = new XmlWriterSettings() { Indent = true };
using (var xmlWriter = XmlWriter.Create(textWriter, settings))
(serializer ?? new XmlSerializer(obj.GetType())).Serialize(xmlWriter, obj, ns);
return textWriter.ToString();
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);