Code
<%@Page Language = "C#" Debug="true" %>
<%@ import Namespace="System.Xml" %>
<script language="C#" runat="server">
void Page_Load()
{
XmlDocument CurrentXml = new XmlDocument();
CurrentXml.Load(Server.MapPath("stocks.xml"));
XmlNode root = CurrentXml.LastChild;
Random rc = new Random();
int RandomNumber;
for (int i = 0; i < root.ChildNodes.Count; i++)
{
RandomNumber = rc.Next(0, 100);
XmlNode child = root.ChildNodes[i];
for (int j = 0; j < child.ChildNodes.Count; j++)
{
if (child.ChildNodes[j].Name == "price")
{
decimal value = decimal.Parse(child.ChildNodes[j].InnerXml);
Random rp = new Random();
decimal RandomPrice = rp.Next(0, (int)value);
RandomPrice = RandomPrice / 10;
string direction = "";
if ((RandomNumber % 2) == 1)
{
direction = "Down";
value = value - RandomPrice;
}
else
{
direction = "Up";
value = value + RandomPrice;
}
child.ChildNodes[j].InnerText = value.ToString();
child.ChildNodes[j + 1].InnerText = direction;
}
}
}
CurrentXml.Save(Server.MapPath("stocks.xml"));
}
</script>