コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: XmlNode.cs プロジェクト: beeblebrox/XmlManager
 public void AddChild(IXmlWriteable child)
 {
     _children.Add(child);
 }
コード例 #4
0
 public static string ToXml(IXmlWriteable root)
 {
     return(ToXml(root, 0));
 }
コード例 #5
0
ファイル: XmlNode.cs プロジェクト: beeblebrox/XmlManager
 public void AddChild(IXmlWriteable child)
 {
     _children.Add(child);
 }
コード例 #6
0
 public void Add(IXmlWriteable node)
 {
     Children.Add(node);
 }
コード例 #7
0
 public void Add(IXmlWriteable node)
 {
     Children.Add(node);
 }