CSharp examples for System.Xml:XML Element
Returns trimmed inner text of given parent element's child element with given name. If there is no such element returns null.
using System.Xml; public class Main{ /// <summary> /// Returns trimmed inner text of given parent element's child element with given name. /// If there is no such element returns null. /// </summary> /// <param name="parentElement"></param> /// <param name="elemName"></param> /// <returns></returns> public static string ReadElementValue(XmlElement parentElement, string elemName) {/*from w ww. ja v a 2 s. co m*/ XmlElement elem = (XmlElement)parentElement.SelectSingleNode(elemName); if (elem != null) { return elem.InnerText.Trim(); } return null; } }