I have this xml, and I am lost reading it, please can anyone help?
<?xml version = "1.0" encoding = "utf-8"?>
<root>
<batch>
<field level = "batch" name = "VoucherNumber" value = "00018"/>
<field level = "batch" name = "FinancialYear" value = "1996"/>
<field level = "batch" name = "CountNumber" value = "00018"/>
<field level = "batch" name = "CountDate" value = "1416-08-16"/>
<field level = "batch" name = "Total" value = "214000.0"/>
<field level = "batch" name = "CuttOf" value = "0.0"/>
<field level = "batch" name = "Net" value = "214000.0"/>
<field level = "batch" name = "Comment" value = "1"/>
<field level = "batch" name = "DailyNumber" value = "00018"/>
<field level = "batch" name = "DailyDate" value = "1416-09-01"/>
<field level = "batch" name = "Year" value = "1416"/>
<field level = "batch" name = "Section" value = "1"/>
</batch>
</root>
I am trying to extract all the names and values and return them, my code as follow:
private string ReadXML(string filename)
{
string str = "";
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlNodeList nodelist = doc.SelectNodes("/root/batch");
foreach (XmlNode node in nodelist)
{
str += node["name"].InnerText + node["value"].InnerText;
}
return str;
}