Xml Value from XPath - CSharp System.Xml

CSharp examples for System.Xml:XPath

Description

Xml Value from XPath

Demo Code


using System.Xml.XPath;
using System.Xml;
using System.Collections.Generic;
using System;/*from ww w .  j  a  v a2s. c  om*/

public class Main{
        public static string XmlVal(XmlDocument d, string path)
      {
         XPathNavigator navigator = d.CreateNavigator();
         XPathNodeIterator iterator = navigator.Select(path);
         foreach (XPathNavigator n in iterator)
         {
            return n.Value;
         }
         return null;
      }
}

Related Tutorials