Reputation: 3
I have this xml file...
<xmlheufthdc src="http://172.16.7.50:8990/xml/heuft/hdc" version="1.0" time="2016-11-23T09:23:43.172Z">
<device name="2NG012550">
<entry name="count_total" status="valid">80849</entry>
</device>
</xmlheufthdc>
I have used c# and been able to access the data under entry name and entry status but i how do i make reference to the number 80849. ie what would i call it rather than name or status.
The code is as follows
public partial class Form1 : Form
{
Form2 form2 = new Form2();
public Form1()
{
InitializeComponent();
}
public string add1;
public string read1;
public string att11;
public string att21;
private void button1_Click(object sender, EventArgs e)
{
}
public void configureToolStripMenuItem_Click(object sender, EventArgs e)
{
form2.Show();
}
private void button2_Click(object sender, EventArgs e)
{
string text1 = "";
string text2;
add1 = form2.add;
read1 = form2.read;
att11 = form2.att1;
att21 = form2.att2;
XmlReader xmlReader = XmlReader.Create(add1);
while (xmlReader.Read())
{
if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == read1))
{
if (xmlReader.HasAttributes)
text1=(xmlReader.GetAttribute(att11) + ": " + xmlReader.GetAttribute(att21));
textBox1.Text = text1;
}
}
}
}
The att items are entred in another form and this is where i would enter. read1 being "entry" and att1 being "name" and att21 being "status".
Sorry im new to this any information would be much appreciated.
Thanks Alistair
Upvotes: 0
Views: 402
Reputation: 457
The number can be accessed by using the InnerText property of XmlNode class.
Upvotes: 1