public static void Write(IXmlWriteable root, string path) { if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, XmlDeclaration); string xml = ToXml(root); File.AppendAllText(path, xml); }
private static string ToXml(IXmlWriteable element, int indents) { string elementname = element.XmlElementName(); string text = element.XmlText(); string xml = StartElementOpen(elementname, indents); IXmlWriteableAttribute[] attribs = element.XmlAttributes(); if (attribs != null) { foreach (IXmlWriteableAttribute a in attribs) { if (a != null) { xml += AddAttribute(a.XmlName(), a.XmlValue()); } } } IXmlWriteable[] children = element.XmlChildren(); if (children != null && children.Length > 0) { xml += EndElementOpen(); indents++; foreach (IXmlWriteable c in children) { if (c != null) { xml += ToXml(c, indents); } } indents--; xml += CloseTag(elementname, indents); } else if (text != "") { xml += AddText(text, elementname); } else { xml += ShortCloseTag(); } return(xml); }
public void AddChild(IXmlWriteable child) { _children.Add(child); }
public static string ToXml(IXmlWriteable root) { return(ToXml(root, 0)); }
public void AddChild(IXmlWriteable child) { _children.Add(child); }
public void Add(IXmlWriteable node) { Children.Add(node); }
public void Add(IXmlWriteable node) { Children.Add(node); }