i got a xml document im loading in C#, and im trying to get nodes by count. My problem is it only takes the last node in the loop. The nodes has an id called 2 but my count start at 0. so it jumbs over two nodes. The thing i want is input form value counting with nodeA["AddonPrice"].InnerText by id because i have multible nodes.
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("./xmlRe/" + filenDato + ".xml"));
int antalAdd0;
int ansver;
int pris;
int total = 0;
XmlNodeList nodeListADDon1 = doc.SelectNodes("TourInfo/AddOns/AddOn");
litTotal.Text = "";
string addon = "";
XmlAttribute xKey = doc.CreateAttribute("Id");
int count = 0;
int adID = 0;
xKey.Value = "addon" + adID;
addon = Request.Form["txtAddonAntal" + count];
antalAdd0 = int.Parse(addon.ToString());
foreach (XmlNode nodeA in nodeListADDon1)
{
nodeA.Attributes.Append(xKey);
pris = int.Parse(nodeA["AddonPrice"].InnerText);
ansver = antalAdd0 * pris;
litAdd.Text = "" + "" + "" + "" + "
" + nodeA["AddonText"].InnerText + " | " + antalAdd0.ToString() + " | Pris: " + ansver.ToString() + " kr |
";
total += ansver;
litTotal.Text += total.ToString() + " kr";