Select Single XML Text Int - CSharp System.Xml

CSharp examples for System.Xml:XPath

Description

Select Single XML Text Int

Demo Code


using System.Xml;
using System;//from www . j  ava  2s.c  o  m

public class Main{
        public static int? SelectSingleTextInt(XmlNode node, string selector, int? defaultValue = null)
    {
        workNode = node.SelectSingleNode(selector, Manager);
        if (workNode != null && int.TryParse(workNode.InnerText, out iTryParse))
        {
            return iTryParse;
        }

        return defaultValue;
    }
}

Related Tutorials