The easiest way to do this is to launch a new browser window using javascript [document.open()], set the content type to XML, and write the XML to the Response stream. The web browser will then control the rendering of the XML. In IE, you get expandable nodes and color coding.
>
Hello All,
>
>I have a Web Service that accepts XML input and returns XML. The XML will be consumed by a third party.
>
>I have designed a simple ASP page to hit the web service. I have two textboxes on the form - one for input, and one that displays the output from the web service. The data (xml) coming back is displayed in the textbox, but I want to format it (indentation, line feeds, etc.) to make it easier to read. Is there an easy way to do this? I know in the IDE if I hit CTRL+K, CTRL+D, the xml is formatted. I want to do this in code on the ASP page. The following is what I am doing now to format the XML:
>
>
> private string FormatXML(string xmlString)
> {
> string retVal = "";
> XmlDocument doc = new XmlDocument();
> doc.PreserveWhitespace = true;
> doc.LoadXml(xmlString);
> System.IO.MemoryStream ms = new MemoryStream();
> XmlTextWriter xtw = new XmlTextWriter(ms, new System.Text.UTF8Encoding(false));
> xtw.Formatting = Formatting.Indented;
> xtw.Indentation = 4;
> doc.Save(xtw);
> byte[] xmlBytes = ms.ToArray();
> foreach (byte b in xmlBytes)
> {
> retVal += (char)b;
> }
> return retVal;
> }
>
>
>This works just fine for a small amount (10K) of data returned, but when the output is aroung 100K or so, it takes forever. Is there an alternative way of formatting this XML in the textbox?
>
>Thanks for you help,
>Pat Moran