CSharp examples for System.Xml:XML Element
Add XML Element To XElement
using System.Xml.Linq; using System;//from ww w .j ava2s. c om public class Main{ public static void AddElem(this XElement elem, string name, Vector4 vect) { var v = new XElement(name); v.AddElem(vect); elem.Add(v); } public static void AddElem(this XElement elem, string name, Vector3 vect) { var v = new XElement(name); v.AddElem(vect); elem.Add(v); } public static void AddElem(this XElement elem, string name, Vector2 vect) { var v = new XElement(name); v.AddElem(vect); elem.Add(v); } public static void AddElem(this XElement elem, Vector4 vect) { var x = new XElement("x", vect.X); var y = new XElement("y", vect.Y); var z = new XElement("z", vect.Z); var w = new XElement("w", vect.W); elem.Add(x, y, z, w); } public static void AddElem(this XElement elem, Vector3 vect) { var x = new XElement("x", vect.X); var y = new XElement("y", vect.Y); var z = new XElement("z", vect.Z); elem.Add(x, y, z); } public static void AddElem(this XElement elem, Vector2 vect) { var x = new XElement("x", vect.X); var y = new XElement("y", vect.Y); elem.Add(x, y); } public static void AddElem(this XElement elem, string name, object v) { elem.Add(new XElement(name, v)); } }