Response.Write for a XML string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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" >
----------^
 
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.
 
I think your comment should be
<!-- Title -->
rather than
<-- Title -->


--
Regards,
Dennis JD Myrén
Oslo Kodebureau
msuk said:
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 said:
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]
- (e-mail address removed)

msuk said:
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" >
----------^
 
And also;
<Mssage>Some text</Message>
should be
<Message>Some text</Message>



--
Regards,
Dennis JD Myrén
Oslo Kodebureau
Dennis Myrén said:
I think your comment should be
<!-- Title -->
rather than
<-- Title -->


--
Regards,
Dennis JD Myrén
Oslo Kodebureau
msuk said:
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
accustomed
to.
Fix the errors in the XML returned, and it should work fine.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

All,

I have a well form block of XML that is stored in a C# string type
and
error
 
msuk,

You also need to set the ContentType property on the response to
"text/xml".


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

msuk said:
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 said:
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]
- (e-mail address removed)

msuk said:
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" >
----------^
 
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 said:
msuk,

You also need to set the ContentType property on the response to
"text/xml".


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

msuk said:
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 said:
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]
- (e-mail address removed)

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" >
----------^
 
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 said:
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 said:
And also;
<Mssage>Some text</Message>
should be
<Message>Some text</Message>



--
Regards,
Dennis JD Myrén
Oslo Kodebureau
Dennis Myrén said:
I think your comment should be
<!-- Title -->
rather than
<-- Title -->


--
Regards,
Dennis JD Myrén
Oslo Kodebureau
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



:

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]
- (e-mail address removed)

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" >
----------^
 
Anyone help please?

Thanks
Msuk

msuk said:
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 said:
msuk,

You also need to set the ContentType property on the response to
"text/xml".


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

msuk said:
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



:

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]
- (e-mail address removed)

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" >
----------^
 
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 said:
Anyone help please?

Thanks
Msuk

msuk said:
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 said:
msuk,

You also need to set the ContentType property on the response to
"text/xml".


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

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



:

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]
- (e-mail address removed)

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" >
----------^
 
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 said:
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 said:
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 said:
Anyone help please?

Thanks
Msuk

:

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" >
----------^



:

msuk,

You also need to set the ContentType property on the response to
"text/xml".


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

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



:

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]
- (e-mail address removed)

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"
----------^
 
Back
Top