Search:
Namespaces
Discussions
.NET v1.1
Feedback
Response.Write for a XML string
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.languages.csharp
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
msuk (VIP)
All,
I have a well form block of XML that is stored in a C# string type and I
just simply want to display it in the browser using Response.Write but when I
try this I get 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/App1/WebForm1.asp..
.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
----------^
Reply to this message...
Nicholas Paldino [.NET/C# MVP] (VIP)
musk,
Basically, your XML is not well-formed, so the browser has problem
displaying it. The browser, by default, applies a stylesheet to the XML
document to show it with the nice tree structure that you are accustomed to.
Fix the errors in the XML returned, and it should work fine.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
Click here to reveal e-mail address
"msuk" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
msuk (VIP)
Hi,
I don't get the nice tree stucture for some reason what am I doing wrong.
StringBuilder
xml = new
StringBuilder
();
xml.Append("<?xml version=" + "\"" + "1.0" + "\"" + "?>\r");
xml.Append ("<-- Title -->\r");
xml.Append ("<T1>\r");
xml.Append ("<Mssage>Some text</Message>\r");
xml.Append ("</T1>\r");
Response.Write (xml);
The display in the browser is as follows:
<-- Title --> Some text
"Nicholas Paldino [.NET/C# MVP]" wrote:
[Original message clipped]
Reply to this message...
Nicholas Paldino [.NET/C# MVP] (VIP)
msuk,
You also need to set the ContentType property on the response to
"text/xml".
--
- Nicholas Paldino [.NET/C# MVP]
-
Click here to reveal e-mail address
"msuk" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
msuk (VIP)
Hi,
I am still getting the same error:
StringBuilder
xml = new
StringBuilder
();
xml.Append("<?xml version=" + "\"" + "1.0" + "\"" + "?>\r\n");
xml.Append ("<!-- Title -->\r\n");
xml.Append ("<T1>\r\n");
xml.Append ("<Message>Some text</Message>\r\n");
xml.Append ("</T1>\r");
Response.ContentType="text/xml";
Response.Write (xml.ToString());
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/responsexml/WebForm1.asp..
.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
----------^
"Nicholas Paldino [.NET/C# MVP]" wrote:
[Original message clipped]
Reply to this message...
msuk (VIP)
Anyone help please?
Thanks
Msuk
"msuk" wrote:
[Original message clipped]
Reply to this message...
Dennis Myrén
> Anyone help please?
Well, I did;
Try to clear the response output stream prior to
writing the XML stream.
Response.ClearContent();
Response.ContentType = "text/xml";
Response.Write(xml.ToString());
If that does not work. Hmm.
Take the XML that you write, place it in a text file and save with XML
extension.
Open in your browser just to see that it works as it should.
I know at least Internet Explorer and Mozilla Firefox both apply builtin
stylesheets to
standalone XML files, so i recommend that you use any of those.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"msuk" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
msuk (VIP)
Hi again,
My C# component returns the XML string that I write out to file and when I
open it in my brower it seems to be fine apart from a base64 encoded tag I
have see below
<file dt:dt="bin.base64">0M8R4KGxG....
that is truncated but if I open the file in notepad it is all there could
this be causing the problem? How can I display the complete file tag
containg in Internet explorer?
Thanks
Msuk
"Dennis Myrén" wrote:
[Original message clipped]
Reply to this message...
Dennis Myrén
Just mail me the material off the list and i will help you out.
dennis at oslokb dot no
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"msuk" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Dennis Myrén
I think your comment should be
<!-- Title -->
rather than
<-- Title -->
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"msuk" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Dennis Myrén
And also;
<Mssage>Some text</Message>
should be
<Message>Some text</Message>
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <
Click here to reveal e-mail address
> wrote in message
news:tzi1d.9319$g%
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
msuk (VIP)
Hi,
Sorry for the typo's but using the following I dont get the XML structure
but just the text "Message"
// Put user code to initialize the page here
StringBuilder
xml = new
StringBuilder
();
xml.Append ("<?xml version=" + "\"" + "1.0" + "\"" + "?>\r\n");
xml.Append ("<VirusChecker>\r\n");
xml.Append ("<Scan>Message</Scan>\r\n");
xml.Append ("</VirusChecker>\r\n");
Response.Write (xml.ToString());
How can I display the XML structure?
Thanks
Msuk
"Dennis Myrén" wrote:
[Original message clipped]
Reply to this message...
Dennis Myrén
Try to clear the response output stream prior to
writing the XML stream.
Response.ClearContent();
Response.ContentType = "text/xml";
Response.Write(xml.ToString());
If that does not work. Hmm.
Take the XML that you write, place it in a text file and save with XML
extension.
Open in your browser just to see that it works as it should.
I know at least Internet Explorer and Mozilla Firefox both apply builtin
stylesheets to
standalone XML files, so i recommend that you use any of those.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"msuk" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.Text.StringBuilder
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com