CSharp examples for System.Xml:XML Element
Get XML Element Text
using System.Xml; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from ww w. j av a2 s .c om*/ public class Main{ public static string GetElementText(this XmlElement element, string childName) { XmlElement childElem = element.GetChildElement(childName); return (childElem != null) ? childElem.InnerText : string.Empty; } 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; } }