Anders Borum wrote:
Hello!
XmlNode firstSoldier = xDoc.SelectSingleNode("Soldiers/Soldier");
Actually, you don't need to specify the indexer as XmlNode.SingleNode
returns the first node if the query results in a XmlNodeList. I like the
explicit query, but I think its worth knowing there's another way to write
the query :-)
Ack - this assumes what I previously said about the structure of my XML
document. I have since found out that there are a few different formats
that my XML files could be in, and the <Soldierssection could be in a
few different places.
I need to obtain the first <Soldierselement *wherever* it may lie in
the XML document - with no assumptions being made about the document's
structure.
Sorry I didn't say explicitly that I've had to give up my assumptions
about the XML files.
But thanks for the answers!
cdj