You might use
XPath
for the purpose. If you are not familiar with
XPath
queries, then have a look at
w3schools XPath tutorial[
^]. You may also find
"World’s Smallest XML XPath Tutorial"[
^] interesting.
The following silly example searches for the Employee 'Norah' and reports her details (warning: no error checking):
using System;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load("empl.xml");
XmlNode xnd = doc.DocumentElement.SelectSingleNode("./Employee[FirstName/text()='Norah']");
Console.WriteLine("ID = {0}, LastName = {1}, Salary = {2}", xnd.ChildNodes[0].InnerText, xnd.ChildNodes[2].InnerText, xnd.ChildNodes[3].InnerText);
}
}
}