Simple XML browser
-
I'd like to create a simple XML browser that displays a XML file an similar way as IE does. I'm not doing anything with the file, just want to display it in a readable way. I have tried with xmlreader and richtextbox classes but not really been successful in formatting the XML in a nice way. reader = new XmlTextReader(xmlfile); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. int curr = 0; int next = 0; while (reader.Read()) { curr = reader.LineNumber; richTextBox2.AppendText(reader.Name); richTextBox2.SelectionColor = Color.Blue; richTextBox2.AppendText(reader.Value); richTextBox2.SelectionColor = Color.Black; if ( curr > next ) next = curr; else richTextBox2.AppendText("\n"); } Is this the right way to go, or should I start looking at other solutions?
-
I'd like to create a simple XML browser that displays a XML file an similar way as IE does. I'm not doing anything with the file, just want to display it in a readable way. I have tried with xmlreader and richtextbox classes but not really been successful in formatting the XML in a nice way. reader = new XmlTextReader(xmlfile); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. int curr = 0; int next = 0; while (reader.Read()) { curr = reader.LineNumber; richTextBox2.AppendText(reader.Name); richTextBox2.SelectionColor = Color.Blue; richTextBox2.AppendText(reader.Value); richTextBox2.SelectionColor = Color.Black; if ( curr > next ) next = curr; else richTextBox2.AppendText("\n"); } Is this the right way to go, or should I start looking at other solutions?
If you want something really simple and quick, just embed the web browser into your application and then navigate to the xml file. - Nick Parker
My Blog | My Articles -
I'd like to create a simple XML browser that displays a XML file an similar way as IE does. I'm not doing anything with the file, just want to display it in a readable way. I have tried with xmlreader and richtextbox classes but not really been successful in formatting the XML in a nice way. reader = new XmlTextReader(xmlfile); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. int curr = 0; int next = 0; while (reader.Read()) { curr = reader.LineNumber; richTextBox2.AppendText(reader.Name); richTextBox2.SelectionColor = Color.Blue; richTextBox2.AppendText(reader.Value); richTextBox2.SelectionColor = Color.Black; if ( curr > next ) next = curr; else richTextBox2.AppendText("\n"); } Is this the right way to go, or should I start looking at other solutions?