Add Xml Content to XElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Add Xml Content to XElement

Demo Code


using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Globalization;
using System.Xml.Linq;
using System;//from ww w . j  av  a2 s.com

public class Main{
        public static XElement AddXmlContent(this XElement self, object contentValue)
        {
            self.Add(new XText(contentValue.ToXmlValue()));
            return self;
        }
        public static string ToXmlValue(this object self)
        {
            return Convert.ToString((self ?? String.Empty), CultureInfo.InvariantCulture);
        }
}

Related Tutorials