Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > display xml in textbox
 

display xml in textbox

Hi,
XmlTextWriter xmlw = new XmlTextWriter("c:\\sun.xml", null);
xmlw.WriteStartDocument();
xmlw.WriteStartElement("Company");
xmlw.WriteStartElement("Skills");
xmlw.WriteElementString("Microsoft", textBox1.Text);
xmlw.WriteElementString("Sun", textBox2.Text);
xmlw.WriteEndElement();
xmlw.WriteEndElement();
xmlw.WriteEndDocument();
xmlw.Close();

I used that above code for writing an xml, now i want to display that xml in text box how to do that?

Santhosh22  Wednesday, July 16, 2008 7:15 AM

Hi!

You can't use the XmlTextWriter to update the textbox. Use the XmlTextReaderinstead to read thexml file.

Regards,

Lucian Baciu  Monday, July 21, 2008 10:00 AM

use XmlTextReaderto read the xml from the file and then display it.

Lucian Baciu  Wednesday, July 16, 2008 10:01 AM

Or you can use the StreamReader to copy all the content in the XML fileto the TextBox:

Code Snippet

(StreamReader sr = new StreamReader(@"c:\test.xml"))

{

this.textBox1.Text = sr.ReadToEnd();

}

Zhi-Xin Ye  Thursday, July 17, 2008 8:11 AM

Hi,

Thank a lot for giving reply

I want to copy from XmlTextwriter not c:\test.xml

bcoz bfore saving only i want to display from memory

Santhosh22  Friday, July 18, 2008 4:31 AM

Hi!

You can't use the XmlTextWriter to update the textbox. Use the XmlTextReaderinstead to read thexml file.

Regards,

Lucian Baciu  Monday, July 21, 2008 10:00 AM

You can use google to search for other answers

Custom Search

More Threads

• Is taskvision free?
• Please Help me
• ParamArray
• Run time Create controls
• SQL Server Location
• Source code, server and future
• Cannot implicitly convert type 'PocketVision.DataSetTasks' to 'PocketVision.DataAccess.DataSetTasks'
• RAR
• A Bug in TaskVision ?!? ( for those puzzled about selections in DataGrid )
• Is it dead?