Writing XML stored in a string using Respose.Write
-
I have some XML tags stored in a string. This data is obtained through remoting. I want the same to be displayed on an HTML page by using a Respose.Write. When I do a Response.write of the string then it loses its XML format and just displays as string alone. Could I know how to display the same in XML format itself. I tried using REsponse.ContenType = "text/xml", But this is giving me an error
-
I have some XML tags stored in a string. This data is obtained through remoting. I want the same to be displayed on an HTML page by using a Respose.Write. When I do a Response.write of the string then it loses its XML format and just displays as string alone. Could I know how to display the same in XML format itself. I tried using REsponse.ContenType = "text/xml", But this is giving me an error
anufabian wrote:
But this is giving me an error
What error?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
anufabian wrote:
But this is giving me an error
What error?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
It gives me the following error :::: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^
-
It gives me the following error :::: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^
Try calling the Clear method before writing the XML string to make sure the HTTP response contains nothing else.
Response.ContenType = "text/xml";
Response.Clear();
Response.Write(xmlString);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Try calling the Clear method before writing the XML string to make sure the HTTP response contains nothing else.
Response.ContenType = "text/xml";
Response.Clear();
Response.Write(xmlString);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
I am still getting the same error. The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^ I assume that the line DOCTYPE HTML... is the firsy line written on an aspx page . Is this causing the problem. I tried to save the xml in a file , it works fine. However my requirement is to display the XML on an aspx page , along with the look and feel of XML .
-
I am still getting the same error. The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^ I assume that the line DOCTYPE HTML... is the firsy line written on an aspx page . Is this causing the problem. I tried to save the xml in a file , it works fine. However my requirement is to display the XML on an aspx page , along with the look and feel of XML .
anufabian wrote:
However my requirement is to display the XML on an aspx page
Ah, I thought you want to send back the pure XML. My fault. Take a look at the
System.Web.UI.WebControls.Xml
control and the continuative links in its documentation. I think they should help you to achieve what you want.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
anufabian wrote:
However my requirement is to display the XML on an aspx page
Ah, I thought you want to send back the pure XML. My fault. Take a look at the
System.Web.UI.WebControls.Xml
control and the continuative links in its documentation. I think they should help you to achieve what you want.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
The above technique did not help me. However I was able to solve the issue by using something like this. Response.Write("" + outputstring + "/xmp>"); This i got it from some one else. However I still dont understand what is the use of <xmp> tag. If possible could you throw some light on this. </x-turndown>
-
The above technique did not help me. However I was able to solve the issue by using something like this. Response.Write("" + outputstring + "/xmp>"); This i got it from some one else. However I still dont understand what is the use of <xmp> tag. If possible could you throw some light on this. </x-turndown>
"The XMP tag displays a sequence of literal characters in the browser's default fixed-width font. The XMP element displays all white space and line breaks exactly as they appear inside the and tags." (HTML Tag Reference[^]) Another resource (SelfHTML[^]) said that the xmp tag is no longer a part of the HTML standard. Though they are still supported by current browsers, one should not count on this. The resource suggests of instead using the pre tag. Since the pre element interprets HTML tags, you must use special symbols for any character that has a meaning in HTML that you wish to be displayed rather than interpreted. For example, use &< for the < symbol, and use &> for the > symbol.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook