I have a XML document online which I'm trying to obtain and display the value of a particular node in a label.
XML:
<h1 class="contents-header">Upper Limit Management</h1>
<div class="contents-body">
<table class="data-table" width="500px">
<tr>
<th scope="col" width="165px">Max. Allowance Set</th>
<th scope="col" width="165px">Max. Allowance</th>
<th scope="col" width="170px">Meter Count</th>
</tr>
<tr>
<td>Disable</td>
<td>0</td>
<td>32</td>
</tr>
</table>
</div>
<hr class="contents-end" title="">
</div>
And here's the C# code I've tried to obtain and display it. I'm trying to display the node "Meter Count" which has a value of 32.
private void loadxmlbtn_Click(object sender, EventArgs e)
{
string myXmlString = new WebClient().DownloadString("http://ift.tt/1xvjUqp");
XmlDocument xml = new XmlDocument();
xml.LoadXml(myXmlString);
XmlNodeList xnList = xml.SelectNodes("/Upper Limit Management/Meter Count");
foreach (XmlNode xn in xnList)
{
string count = xn["td"].InnerText;
countlbl.Text = "Your current count is: " + count;
}
}
However, on the button click, nothing is happening. Is anyone able to point out what might be going wrong?
Aucun commentaire:
Enregistrer un commentaire