Hi Oswaldlily,
Here is the solution for you: I'm sure there may be simple way than this, as i am a beginner i tried this way.
ASP Page:
Empty.
CodeBehind:
protected void Page_Load(object sender, EventArgs e)
{
Dictionary<string, string> Items = new Dictionary<string, string>();
DataSet dset = new DataSet();
dset.ReadXml(Server.MapPath("~/DictionaryItems.xml"));
StringBuilder strbkey = new StringBuilder();
foreach (DataRow row in dset.Tables[0].Rows)
{
strbkey.Append(row["col1"]+" ");
}
string x = strbkey.ToString();
string[] keys = x.Split(' ');
StringBuilder strbvalue = new StringBuilder();
foreach (DataRow row in dset.Tables[0].Rows)
{
strbvalue.Append(row["col2"].ToString()+" ");
strbvalue.Append(row["col3"].ToString()+" | ");
}
string y = strbvalue.ToString();
string[] values = y.Split('|');
for (int i = 0; i < values.Count(); i++)
{
Items.Add(keys, values);
}
foreach (KeyValuePair<string, string> item in Items)
{
Response.Write(item);
}
}
Your Xml File: DictionaryItems.xml
<Tables>
<Column col1="c1" col2="c2" col3="c3" />
<Column col1="s1" col2="s2" col3="s3" />
</Tables>
Regards,
Awesome Coding !! :)
Oswaldlily, if this helps please login to Mark As Answer. |
Reply | Alert Moderator