Bonjour a tous j'utilise un webservice et je gere des fichiers XML

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
<setting>
  <Profile id="2">
    <Split ID="Bottom" Height="174" Width="800" />
    <Split ID="Left" Height="97" Width="392" />
    <Split ID="Right" Height="410" Width="392" />
  </Profile>
</setting>
Je cherche à inserer un profile de la facon suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
<setting>
  <Profile id="2">
    <Split ID="Bottom" Height="174" Width="800" />
    <Split ID="Left" Height="97" Width="392" />
    <Split ID="Right" Height="410" Width="392" />
  </Profile>
  <Profile id="3">
    <Split ID="Bottom" Height="174" Width="800" />
    <Split ID="Left" Height="97" Width="392" />
    <Split ID="Right" Height="410" Width="392" />
  </Profile>
</setting>
Voila mon code

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
 
    [WebMethod]
    public bool Insert(string id, string text)
    {
        if (IsFileExist(path))
        {
            XmlNode currNode;
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
            docFrag.InnerXml = "<Profile id=\"" + id + "\"><Split ID=\"Bottom\" Height=\"" + text + "\" Width=\"" + text + "\"/><Split ID=\"Left\" Height=\"" + text + "\" Width=\"" + text + "\"/><Split ID=\"Right\" Height=\"" + text + "\" Width=\"" + text + "\"/></Profile>";
            currNode = doc.DocumentElement.FirstChild;
            currNode.InsertAfter(docFrag, currNode.LastChild);
            doc.Save(path);
            return true;
        }
        return false;
    }
Je sais que c'est un probleme de positionnement avec currNode
car j'obtient ceci pour l'instant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
<setting>
  <Profile id="2">
    <Split ID="Bottom" Height="174" Width="800" />
    <Split ID="Left" Height="97" Width="392" />
    <Split ID="Right" Height="410" Width="392" />
    <Profile id="3">
      <Split ID="Bottom" Height="174" Width="800" />
      <Split ID="Left" Height="97" Width="392" />
      <Split ID="Right" Height="410" Width="392" />
    </Profile>
  </Profile>
</setting>
Merci de votre aide