XML





XMLDocument


using System.Xml; { //インスタンスの生成 XmlDocument doc = new XmlDocument(); //XMLの読み込み doc.Load("d:/test.xml"); //ルートノードの参照 XmlNode root = doc.DocumentElement; //要素ノードの作成して追加 XmlElement e = doc.CreateElement("test"); root.PrependChild( e ); //テキストノードの作成 XmlCharacterData text = doc.CreateTextNode("foo"); e.PrependChild( text ); // Attribute 追加 e.SetAttribute( "id", "10" ); //XMLの保存 doc.Save( "d:/out.xml" ); }