Hi,

I have a string with XML in it. I want to display this xml in a windows
form.

I have looked at Microsoft Web Browser control, but it seems to want to work
with a url. How can I just pass my xml string for displaying?

Thanks
Martin

Re: Display XML held in a string by Martin

Martin
Wed Sep 29 06:11:33 CDT 2004

I should say I want it displayed nicely - not just as a plain bit of text.

"Martin" <x@y.z> wrote in message
news:e2j$YpgpEHA.3300@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I have a string with XML in it. I want to display this xml in a windows
> form.
>
> I have looked at Microsoft Web Browser control, but it seems to want to
work
> with a url. How can I just pass my xml string for displaying?
>
> Thanks
> Martin
>
>



Re: Display XML held in a string by Sijin

Sijin
Wed Sep 29 12:10:28 CDT 2004

You can always roll your own solution, just use something like the
IndentedTextWriter to write the various elements of the XML into a
neatly formatted stream and then display the string from the stream in a
RichTextBox, btw you can also write the XML string to a temp file and
then pass the location of that file as a URL to the webbrowser control.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph


Martin wrote:
> I should say I want it displayed nicely - not just as a plain bit of text.
>
> "Martin" <x@y.z> wrote in message
> news:e2j$YpgpEHA.3300@TK2MSFTNGP12.phx.gbl...
>
>>Hi,
>>
>>I have a string with XML in it. I want to display this xml in a windows
>>form.
>>
>>I have looked at Microsoft Web Browser control, but it seems to want to
>
> work
>
>>with a url. How can I just pass my xml string for displaying?
>>
>>Thanks
>>Martin
>>
>>
>
>
>

RE: Display XML held in a string by BKStrelioff

BKStrelioff
Sun Jan 23 13:05:02 CST 2005

I have run into the same problem. The workaround I am using is to place the
XML in a file. The other methods listed below are things I tried that didn't
work.

// File IO overhead
string tempUrl = @"C:\temp\docs\temp.xml";
FileInfo tempFile = new FileInfo(tempUrl);
if (tempFile.Exists)
{
tempFile.Delete();
}
StreamWriter writer = new StreamWriter(tempFile.OpenWrite());
writer.Write(splitDocument.DocumentXmlString);
writer.Close();
this.webBrowser1.Url = tempUrl;

//Won't format
//MemoryStream temp = new MemoryStream();
//StreamWriter writer = new StreamWriter(temp);
//writer.Write(splitDocument.DocumentXmlString);
//writer.Flush();
//temp.Position = 0;
//this.webBrowser1.DocumentStream = temp;

// Won't format
//Encoder utf8encoder = Encoding.UTF8.GetEncoder();
//char[] charArray = splitDocument.DocumentXmlString.ToCharArray();
//byte[] byteArray = new byte[utf8encoder.GetByteCount(charArray, 0,
byteArray.Length, true)];
//int charsUsed;
//int bytesUsed;
//bool completed;
//utf8encoder.Convert(charArray, 0, charArray.Length, byteArray, 0,
byteArray.Length, true,
// out charsUsed, out bytesUsed, out completed);
//this.webBrowser1.DocumentStream = new MemoryStream(byteArray);