using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
public class MainClass
{
public static void Main()
{
XPathDocument doc = new XPathDocument(Application.StartupPath + @"\employees.xml");
XPathNavigator navigator = doc.CreateNavigator();
XPathExpression expression = navigator.Compile("xpath");
XPathNodeIterator iterator = navigator.Select(expression);
try
{
Console.WriteLine("The expressions returned " + iterator.Count + " nodes");
if (iterator.Count > 0)
{
while (iterator.MoveNext())
{
Console.WriteLine(iterator.Current.OuterXml);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
|