Hello ,
Am still working on my first C# winforms application .
I populate a TREEVIEW with data from a XML file .
My xml file is like this



 

 
 
 
 
 





I CAN POPULATE DATA IN MY TREEVIEW

My next step is te choose some node ( with attributes ) and  write them in a new XML file ( or an existing one ) similar to the XML source file
this line dont change in the new file

< source rt="2012"  ez= "123">
< start  id="001" />

A wanna just choose object with all childs , or only child and put them in the xml file


they are some exp in the net , i used them but it's not ok , some errors which i don't understand :(

Am working with this code :



public void SerializeTreeView(TreeView treeView, string fileName)


        {


           


XmlWriterSettings settings = new XmlWriterSettings();


            settings.Indent =


true;



           


XmlWriter textWriter = XmlWriter.Create(@"C:\Users\buenb\Documents\projet\EEE.XML", settings);



           


// Writing the xml declaration tag


            textWriter.WriteStartDocument();



           


// Save the nodes, recursive method


            SaveNodes(treeView.Nodes, textWriter);



// End the xml document

            textWriter.WriteEndDocument();

            textWriter.Close();


        }


private void SaveNodes(TreeNodeCollection nodesCollection, XmlWriter textWriter)


        {


for (int i = 0; i < nodesCollection.Count; i++)


            {


               


TreeNode node = nodesCollection[i];


if (node.Nodes.Count > 0)

                {

                    textWriter.WriteStartElement(node.Text);

               }

else


                {


                    textWriter.WriteAttributeString(node.Text,


"Attribute value");


                }



               


if (node.Nodes.Count > 0)


                    SaveNodes(node.Nodes, textWriter);



               


if (node.Nodes.Count > 0)


                    textWriter.WriteEndElement();


            }


        }




Some one can help me to start plz !!
plz !!


thank u all