basic search and sort xml questions

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a few questions about how to go about writing/reading xml files in C#.
So I have a basic xml file that looks like this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; aisles<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; aisle <span style="color:Red; number <span style="color:Blue; = <span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >"some name"<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; description<span style="color:Blue; >"blah blah"<span style="color:Blue; </<span style="color:#A31515; description<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; aisle<span style="color:Blue; >
.
.
.
.
<span style="color:Blue; <<span style="color:#A31515; aisles<span style="color:Blue; >
[/code]
How can I go about checking if a number already exists? Will something like this work:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; while (textReader.Read())
{
<span style="color:Blue; if (textReader.Name == <span style="color:#A31515; "number" && textReader.Value == aisleNumber.ToString())
{
<span style="color:Blue; return <span style="color:Blue; false;
}
}
[/code]
And my last question is how can I go about sorting the xml file by aisle number? Or is this a bad idea? There wont be that many nods. I would say no more then 30.

View the full article
 
Back
Top