Bonjour
Je travaille avec visual studio 2008 et silverlight3 , je veux changer dans mon fichier xml alors voilà la procedure que j'ai cré :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
[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;   
        }
 
 
        [OperationContract]
        public List<ChampsAct> ChampsForAct(string NameFich)
        {
            XDocument data = XDocument.Load(HttpContext.Current.Server.MapPath(@"ClientBin/Data/" + NameFich + ".xml"));
            List<ChampsAct> list = new List<ChampsAct>();
            var req = (from c in data.Descendants("Activity")
                       select new
                       {
 
                           Activity_Name = c.Attribute("ActivityName").Value,
                           Activity_Rule = c.Attribute("ActivityRule").Value
 
                       }).ToList();
 
            if (req == null)
            {
 
                return null;
            }
            else
            {
                foreach (var item in req)
                {
                    list.Add(new ChampsAct(item.Activity_Name, item.Activity_Rule));
                }
                return list;
 
            }
        }
le problème avec setValu l'execution se passe sans erreurs mais ya pas de modification dans mon fichier xml , rien ne se passen
pouvez vous m'aider SVP
Merci d'avance