Get XML Child Node Text - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Get XML Child Node Text

Demo Code


using System.Xml;
using System;//from  w  w w  .  j a v a2  s .co m

public class Main{
        public static string ChildNodeText(XmlNode node, string tag, string defaultValue)
      {
         XmlNode childNode = node.SelectSingleNode(tag);
         return childNode != null ? childNode.InnerText : defaultValue;
      }
        public static string ChildNodeText(XmlNode node, string tag)
      {
          var childNode = node.SelectSingleNode(tag);
         return childNode==null?string.Empty:childNode.InnerText;
      }
}

Related Tutorials