To use this example, its important to note i added a single enclosing tag callled results arround your xml, this is so that the xml parser would not throw a tantrum...
<results>
<ResultPlace PlaceNo="1">
<Result RunnerNo="6" PoolType="PP" Ref50Pct="N" RefScratched="N" RefAbandon="N" RefNoWinner="N" NoPlacePool="N">
<PoolResult PoolType="PP" Dividend="2.40"/>
</Result>
<Result RunnerNo="6" PoolType="WW" Ref50Pct="N" RefScratched="N" RefAbandon="N" RefNoWinner="N" NoPlacePool="N">
<PoolResult PoolType="WW" Dividend="10.00"/>
</Result>
</ResultPlace>
<ResultPlace PlaceNo="2">
<Result RunnerNo="3" PoolType="PP" Ref50Pct="N" RefScratched="N" RefAbandon="N" RefNoWinner="N" NoPlacePool="N">
<PoolResult PoolType="PP" Dividend="2.50"/>
</Result>
<Result RunnerNo="3" PoolType="WW" Ref50Pct="N" RefScratched="N" RefAbandon="N" RefNoWinner="N" NoPlacePool="N">
<PoolResult PoolType="WW"/>
</Result>
</ResultPlace>
<ResultPlace PlaceNo="3">
<Result RunnerNo="4" PoolType="PP" Ref50Pct="N" RefScratched="N" RefAbandon="N" RefNoWinner="N" NoPlacePool="N">
<PoolResult PoolType="PP" Dividend="1.20"/>
</Result>
<Result RunnerNo="4" PoolType="WW" Ref50Pct="N" RefScratched="N" RefAbandon="N" RefNoWinner="N" NoPlacePool="N">
<PoolResult PoolType="WW"/>
</Result>
</ResultPlace>
</results>
To read this xml in c#, you could do the following...
public void ReadPools()
{
XmlDocument doc = new XmlDocument();
doc.Load("results.xml");
XmlNode results = doc.FirstChild;
foreach (XmlNode node in results.ChildNodes)
{
int PlaceNo = int.Parse(node.Attributes["PlaceNo"].Value);
string message = string.Format("Place No: {0}\n", PlaceNo);
foreach (XmlNode result in node)
{
string PoolType = result.Attributes["PoolType"].Value;
message += string.Format("Pool Type: {0}\n", PoolType);
}
MessageBox.Show(message);
}
}
I hope this helps :)
Aimee.
!--removed tag-->
Enter your message below
Sign in or Join us (it's free).