1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
[OperationContract]
public string ChangerAct(string NameFich, string NameActv, string NewNameAct)
{
string chaine="";
string a = "";
XDocument data = XDocument.Load(HttpContext.Current.Server.MapPath(@"~/ClientBin/Data/" + NameFich + ".xml"));
try
{
var req = (from c in data.Descendants("Activity")
where c.Attribute("ActivityName").Value.Equals(NameActv)
//UpdateRowSource c.Attribute("ActivityName")).FirstOrDefault().Value
select c.Attribute("ActivityName")).FirstOrDefault().Value.ToString();
//select c.Attribute("ActivityName")).ToString();
var req2 = (from q in data.Descendants("Activity")
where q.Attribute("ActivityName").Value.Equals(NameActv)
select q.Attribute("ActivityName")).FirstOrDefault();
req2.Value = NewNameAct;
//XElement elt = new XElement("Activities", from p in data.Descendants("Activity")
// select (new XElement("Ativity",
// new XAttribute("ActivityName", "eeee"))));
XElement elt = new XElement("Activities", (from p in data.Descendants("Activity")
where p.Attribute("ActivityName").Value.Equals(NameActv)
select p.Attribute("ActivityName")).FirstOrDefault());
elt.SetAttributeValue("ActivityName1", "erty");
// elt.Save(HttpContext.Current.Server.MapPath(@"~/ClientBin/Data/New/" + NameFich + ".xml"));
////elt.RemoveAttributes();
//req.Replace(req, NewNameAct);
//req = NewNameAct;
//chaine = req;
//data.Save(HttpContext.Current.Server.MapPath(@"~/ClientBin/Data/New/" + NameFich + ".xml"));
}
catch (Exception ex)
{
return ex.ToString();
}
return chaine;
} |
Partager