You can add to your class property attribute [XmlAttribute]
and that property will be serilized as attribute
[XmlRoot(ElementName = "RootXML")]
public class Apply
{
private string _testAttr="dfdsf";
[XmlAttribute]
public String TestAttr
{
get { return _testAttr; }
set { _testAttr = value; }
}
}
Serialization result for that class
<RootXML TestAttr="dfdsf" />
Added for last comment. If i understand correctly you need to have only one key in session. If it true, that you can use something like that:
string GetKey(){
if (String.IsNullOrEmpty(HttpContext.Current.Session["mySessionKey"].ToString()))
HttpContext.Current.Session["mySessionKey"] = GenereteKey();
return HttpContext.Current.Session["mySessionKey"].ToString();
}