This is my recommendation, assuming we have some XML like this:
<root>
<person name="Bart" ssn="123" />
<person name="Marge" ssn="234" />
</root>
<snippet>
string filename = "C:\people.xml", ssn = "123";
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlNode resultNode = doc.DocumentElement.SelectSingleNode
(string.Format("person[@ssn='{0}']", ssn));
if (null != resultNode)
Console.WriteLine("SSN number {0} belongs to {1}!", ssn,
resultNode.Attributes ["name"].InnerText);
else
Console.WriteLine("SSN number {0} does not exist.", ssn);
</snippet>
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mark" <mf****@idonotlikespam.cce.umn.edu> wrote in message
news:eb**************@TK2MSFTNGP10.phx.gbl...
I have a single XML file containing forty records, with no child nodes.
For example, imagine a list of people's names, and birthdates with SSN.
I'd like to find the row of a person with SSN of 123456789. What's the
quickest way to:
1. Load the file from disk.
2. Find the "record" I want.
3. Walk through the other "fields" in this record to get birthdate, first
name and last name for this person?
For example, should I load the file into a DataSet, or use the XMLDocument
class? I will NOT be binding the data to a DataGrid or similar.
Thanks in advance.
Mark