CSharp examples for System.Xml:XML Element
Get Child XML Element
using System.Xml; using System.Text; using System.Linq; using System.Collections.Generic; using System;//w w w. j a v a 2s.co m public class Main{ public static XmlElement GetChildElement(this XmlElement parent, string elemName) { XmlElement element = parent.SelectSingleNode(elemName) as XmlElement; if (element == null) element = parent.CreateChildElement(elemName); return element; } public static XmlElement CreateChildElement(this XmlElement parent, string elemName) { XmlElement element = parent.OwnerDocument.CreateElement(elemName); parent.AppendChild(element); return element; } }