hi ...
i have a query i have created an application in c# i have put this code in button

string strXmlPath = "";
            XmlDocument doc = new XmlDocument();
            strXmlPath = ("C:/App_Data/Document.xml");
            DataSet ds = new DataSet();
            XmlTextWriter writer = new XmlTextWriter(strXmlPath,System.Text.Encoding.UTF8);

         
            writer.WriteStartElement("folder");
            writer.WriteElementString("FolderName", "App_Data");
            writer.WriteElementString("FolderPath", "C:/App_Data/Document.xml");
            writer.WriteEndElement();
           writer.WriteStartElement("folder2");
            writer.WriteElementString("FolderName", "App_Data");
            writer.WriteElementString("FolderPath", "C:/App_Data/Document.xml");
            writer.WriteEndElement();
            ds.WriteXml(@strXmlPath, System.Data.XmlWriteMode.WriteSchema);
            writer.WriteElementString("FolderName", "App_Data");
            writer.WriteElementString("FolderPath", "C/App_Data/Document.xml");
            writer.WriteEndElement();
            //XmlNode parentNode = doc.DocumentElement;
            //XmlNode bookNode = doc.CreateNode(XmlNodeType.Element, "book", null);
            //doc.AppendChild(bookNode);
            //XmlAttribute attr = doc.CreateAttribute("space");
            //attr.InnerText = "4";
            //bookNode.Attributes.Append(attr);
            // Flush

   //DisplayCatalog();
           
            writer.Close();
      
        }

but it couldnt works

i wish i could display an XML file in TextBox or TreeView plz help me out ..

Hi Dear,
Here i have a suggestion for u, I am not sure if it will be useful in your case but still i am sharing. I was also wufering to open an xml file with proper formating then after googling i found that we can use the web browser control to open the xml files

I am sure that this will increase your knowledge as well.

Use the WebBorwser control and set it's navigate property it will show the file.
Be sure to pass it complete file name with directory info
such as:

"C:/App_Data/Document.xml"

Regards,

Hi Dear,
Here i have a suggestion for u, I am not sure if it will be useful in your case but still i am sharing. I was also wufering to open an xml file with proper formating then after googling i found that we can use the web browser control to open the xml files

I am sure that this will increase your knowledge as well.

Use the WebBorwser control and set it's navigate property it will show the file.
Be sure to pass it complete file name with directory info
such as:

"C:/App_Data/Document.xml"

Regards,

Hi:
thx Masood 4 sharing ur knowlege..bt it woudnt works.....!wht else should i do.?i realy cant figure out y it wont display in listBox or treeView. do u have any other idea..
thx Best Regards.
TC

To display an xml in tree view or listbox i would recommend loading it into the XmlDocument class. This way you already have a tree. Then you can jsut parse through it and add what ever fields you would like and skip whatever you done want.
If you want to create a xml document the xml writer is a good class but it does allow possibilities for alot of errors for example forgetting to close and elelemt.
you can instead make the xml file using the xml writer and make the document element.
close the file and load it into the XmlDocument.
now you can just create elements and attributes easily by
XmlElement element=XmlDoc.CreateElement("name");
and set teh inner text, attributes and such from there.

look at something like this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.