Xml Values from XPath - CSharp System.Xml

CSharp examples for System.Xml:XPath

Description

Xml Values from XPath

Demo Code


using System.Xml.XPath;
using System.Xml;
using System.Collections.Generic;
using System;//w  w  w  . j av a 2s  . c o m

public class Main{
        public static IEnumerable<string> XmlVals(XmlDocument d, string path)
      {
         XPathNavigator navigator = d.CreateNavigator();
         XPathNodeIterator iterator = navigator.Select(path);
         foreach (XPathNavigator n in iterator)
         {
            yield return n.Value;
         }
      }
}

Related Tutorials