Reading/Comparing Data from an XML (Basic)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi guys,
I am about half way through my coding of a small program and i am a little stuck. instead of asking for code or anything like that for my actual program, i am creating a little practice program with the same sort of principle.. now i got this one working
sort of using hard coded arrays that store data in them. i want to try and get rid of all the arrays and store the data into an XML file. this way if extra data wants to be added at a later date, it can be easily added, or changed and so on.

ok, for this little practice program. So far i have it so it scans a directory using a recursive search algorithm. I am then checking doing a check on each file as it gets it from the directory and reading the data in the file. i have a set of data stored
in different arrays. so basicly, I have sports, which are football, tennis etc. then i have games, which are CS or monopoly and so on. if the file contains any of the text related to the sport of the game, it displays the file name in a listbox in relation
to the subject.

So for example: if 1 of the files is called bloppyboo.txt and it contains text the game consists of an 11 man team and in my stored arrays I have an array called Football and it contains 11 man team the program then displays the file name into a list
box called "ListSports" because football is a sport and the bloppyboo.txt" file contains information on football. obviously this example is quite silly i know my geniuin application is related to something totally different and far more complex. but right
now all i am asking for is something basic like this so i have a sort of stepping stone.

my aim as i said is to use an XML file instead. Maybe something like below:

<?xml version="1.0"?>
<References>
<sports>
<Ref type = "football 11 man team</Ref>
<Ref type = "tennis 40 love</Ref>
<Ref type = "cricket hit a 6</Ref>
</sports>

<games>
<Ref type = "monopoly take 200</Ref>
<Ref type = "CS counter terrorists</Ref>
<Ref type = "fallout collect caps</Ref>
</games>
</References>
<br/>

as you can see from the xml file, it contains Sports which then contains all sports. so anything thats found in that section, gets stored in the Sports listbox. and so on and so on.
<br/>

I dont really want to provide my code i have at the moment as is hard coded and does contain some sensetive data that I cant share. and a prime reason why im interested in XML coz the data will forever be changing so an XML offers the user the ability
to update it without making changes to the program.
<br/>

Before anyone says, I have tried researching on XMLReader... but i will be straight, i am not a good C# programmer. and i have sat now for 2 days straight trying to understand example codes online and they just seem far to complicated compared to what
i am trying to achieve which is just a "Read file, compare to data in xml file, display in listbox".
<br/>

if anyone could provide with a small piece of code i would be extremely greatful.
<br/>

many thanks in advance,
Hypeh

[EDIT] just to note! although the data is stored in arrays for both the text taken from the file! and the stored arrays. i have converted them to string before comparing. so when the data is pulled from the XML i would need it converted to a string first
before comparing right?

<
m00

View the full article
 
Back
Top