Last post Aug 15, 2008 01:38 PM by Garrydias
Jul 30, 2008 12:37 PM|amstar|LINK
I am a complete newbie to asp .net. Here is my problem.
A user can enter a URL like "http://........../default.aspx?xx=11&yy=22&zz=33"
I need to use the parameters xx,yy and zz and run a stored procedure and get data. Then I have to display this data as xml content. I can form a xml file but I am not able to display it as xml as it is in the file. If I load the xml file stored on the disk
using document source then it just displays the contents as a string without the tags and no formatting either. Even is there a way to avoid writing to a file and then displaying?
Thanks in advance.
asP .NET 2
Jul 30, 2008 12:57 PM|shados|LINK
The xml control is better used if you have an XSLT to transform the document.
What I'd do is make sure to use the HtmlEncode method on your XML, and simply set the text property of a Literal control to your xml string. Problem solved. (you may want to search and replace New Lines with <br /> -after- the html encoding, though, to preserve
line breaks and stuff)
Jul 30, 2008 01:03 PM|amstar|LINK
Thanks for you reply contributer.
But I do not have an xslt and is it required because all that I want to do is display however it is stored on the file. I do not want to format it or something.
Jul 30, 2008 01:06 PM|shados|LINK
Look at the second part of my post, I explained to you how to do it :)
The issue with just using the XML control is that XML tags will be interpreted by the browser as HTML tags... so they end up hidden, newlines go away, etc.
You need to transform it somehow... at the minimum, HTMLEncode will convert < and > into < and >, if you do a search and replace for newlines and replace with <br>, you'll get your newlines, and so on.
Jul 30, 2008 05:31 PM|amstar|LINK
here is the code which worked for me....
Response.ContentType = "text/xml;charset=UTF-8";
string xmlString = xmldocument.InnerXml;
The last line is very important.
Aug 15, 2008 01:38 PM|Garrydias|LINK
how can I set a XSLT output to Text property of a <asp:Literal