I'm complete rookie I need to retrieve the value of last id in XML file here is my XML and then I want to add 1 to that to make a unique id. How would I go about doing that?
<?xml version="1.0" standalone="yes"?>
<bookstore>
<book ID="yepppppppp" title="Harry Potter" price="10" quantity="100" />
<book ID="1" title="Harry Potter" price="10" quantity="100" />
<book ID="10" title="Harry Potter" price="10" quantity="100" />
<book ID="10" title="Harry Potter" price="10" quantity="100" />
<book title="Harry Potter" price="10" quantity="100" />
<book title="Harry Potter" price="10" quantity="100" />
<book title="Harry Potter" price="10" quantity="100" />
<book title="Harry Potter" price="10" quantity="100" />
<book ID="1" title="Dracula by Bam Stoker" price="14.95" quantity="11">
</book>
<book ID="2" title="The Virtues of War A Novel of Alexander the Great" price="10.95" quantity="5">
</book>
<book ID="3" title="Man Walks Into A Bar" price="9.00" quantity="6">
</book>
<book ID="4" title="Encyclopedia of Modern Bodybuilding" price="30.75" quantity="12">
</book>
<book ID="5" title="Your Mortgage and How to Pay it off in Five Years" price="15.00" quantity="4">
</book>
</bookstore>
And C#
protected void Button1_Click(object sender, EventArgs e)
{
System.Xml.XmlDocument myXml = new System.Xml.XmlDocument();
myXml.Load(Server.MapPath("~/purchases.xml"));
System.Xml.XmlNode xmlNode = myXml.DocumentElement.FirstChild;
System.Xml.XmlElement xmlElement = myXml.CreateElement("book");
xmlElement.SetAttribute("ID", );
xmlElement.SetAttribute("title", Server.HtmlEncode(txtTitle.Text));
xmlElement.SetAttribute("price", Server.HtmlEncode(txtPrice.Text));
xmlElement.SetAttribute("quantity", Server.HtmlEncode(txtQuantity.Text));
myXml.DocumentElement.InsertBefore(xmlElement, xmlNode);
myXml.Save(Server.MapPath("~/purchases.xml"));
lblSumarry.Text = "Record inserted into XML file successfully";
}