I am trying to get the currencycode from following xml file. But I get an exception called IndexOutOfRange.
<string xmlns="http://www.webserviceX.NET">
<NewDataSet>
<Table>
<Name>India</Name>
<CountryCode>in</CountryCode>
<Currency>Rupee</Currency>
<CurrencyCode>INR</CurrencyCode>
</Table>
<Table>
<Name>India</Name>
<CountryCode>in</CountryCode>
<Currency>Rupee</Currency>
<CurrencyCode>INR</CurrencyCode>
</Table>
</NewDataSet>
</string>
Here is my code,
string firstCurrency = countryService.GetCurrencyByCountry(this.DropDownList1.SelectedIndex.ToString());
DataSet dataset = new DataSet();
dataset.ReadXml(new XmlTextReader(new StringReader(firstCurrency)));
String currency = dataset.Tables[0].Rows[0][2].ToString();
String currencyCode = dataset.Tables[0].Rows[0][3].ToString();
currencyLabel.Text = currency;
currencyCodeLabel.Text = currencyCode;
Error occurs at the following line,
String currency = dataset.Tables[0].Rows[0][2].ToString();
I tried several hours, but could not find a solution.