My xml document is as follows (but much larger and not anything to do with date of birth info). It is produced by a method and I want to access information from it.
I would like to look up a "Name" like John or Hannah and get DOB from the next line and perhaps put them into a Dictionary<string,string>
for later look-up.
The document is ALWAYS in this form and Names are unique. I only need the first section name = "DOBs".
<info>
<section name="DOBs">
<table>
<headers>
<cell value="Name" />
<cell value="DOB" />
</headers>
<row>
<cell value="John" />
<cell value="121245" />
</row>
<row>
<cell value="Hannah" />
<cell value="050595" />
</row>
</table>
</section>
<section name="notDOBs">
<table>
<headers>
<cell value="Name" />
<cell value="other info" />
</headers>
<row>
<cell value="Hannah" />
<cell value="blue" />
</row>
....
</table>
</section>
</info>
What have I tried? - to be honest, not a lot as I'm confused about xml in general. I've looked at a few SO entries: Xml Reader,This one and How to use XMLreader to read this xml. I also looked at csharp-examples.net which looked good but I kept getting errors about "not leading to node set".
I got excited when I found this: get xml attribut values but no joy, it doesn't seem to find them only the ones.
var myXml = XElement.Load(_myPath).Elements();
var myArray = myXml.Elements("cell").Attributes("value").Select(n => n.Value);
I know I have a LOT more work to do but sometimes you just have to bite the bullet and ask ... Can anyone help?