Response.Write表示XML字符串 [英] Response.Write for a XML string

查看:81
本文介绍了Response.Write表示XML字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,


我有一个存储在C#字符串类型中的格式良好的XML块,而我只需要在b
中显示它使用Response.Write的浏览器但是当我试试这个时我得到以下错误:


无法显示XML页面

无法使用XSL样式表查看XML输入。请更正错误并单击刷新按钮,或稍后再试。

------------------ -------------------------------------------------- ------------


在序言之外不能有DOCTYPE声明。处理错误

资源''http://localhost/App1/WebForm1.asp ...

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN" >

---------- ^

解决方案

麝香,


基本上,您的XML格式不正确,因此浏览器显示问题

。默认情况下,浏览器将样式表应用于XML

文档,以使用您习惯使用的漂亮树结构显示它。


修复错误在返回的XML中,它应该可以正常工作。


希望这会有所帮助。

-

- Nicholas Paldino [。 NET / C#MVP]

- mv*@spam.guard.caspershouse.com

" msuk" < MS ** @ discussions.microsoft.com>在消息中写道

新闻:9A ********************************** @ microsof t.com ...

全部,

我有一个很好的XML格式,存储在C#字符串类型中,我只想简单地想要使用Response.Write在浏览器中显示它但是
当我试试这个时我收到以下错误:

无法显示XML页面
无法查看XML输入使用XSL样式表。请更正错误并
然后单击刷新按钮,或稍后再试。

---------------------- -------------------------------------------------- --------

在序言之外不能有DOCTYPE声明。处理错误
资源''http://localhost/App1/WebForm1.asp ...
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional / / EN" >
---------- ^



我认为你的评论应该是

<! - Title - >

而不是

< - Title - >

- -

问候,

DennisJDMyrén

Oslo Kodebureau

" msuk" < MS ** @ discussions.microsoft.com>在消息中写道

news:41 ********************************** @ microsof t.com ...



由于某种原因,我没有得到漂亮的树状结构我做错了什么。
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);

浏览器中的显示如下:

< - 标题 - >一些文字

Nicholas Paldino [.NET / C#MVP]"写道:

麝香,

基本上,你的XML格式不正确,所以浏览器有问题显示它。默认情况下,浏览器将样式表应用于XML
文档,以使用您习以为常的漂亮树结构来显示它。$ block $ class =post_quotes>


修复返回的XML中的错误,它应该可以正常工作。

希望这会有所帮助。

-
- Nicholas Paldino [。 NET / C#MVP]
- mv*@spam.guard.caspershouse.com
msuk < MS ** @ discussions.microsoft.com>在消息中写道
新闻:9A ********************************** @ microsof t.com。 ..

全部,

我有一个很好的XML格式,存储在C#字符串类型和
我只是想在它中显示它浏览器使用Response.Write但
当我试试这个时我收到以下错误:

无法显示XML页面
无法使用XSL样式表查看XML输入。请更正错误
,然后单击刷新按钮,或稍后再试。


-------------- -------------------------------------------------- ----------



------


在prolog之外不能有DOCTYPE声明。错误
处理资源''http://localhost/App1/WebForm1.asp ...
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional / / EN" >
---------- ^




< blockquote>还有;

< Mssage>一些文字< /消息>

应该是

<消息>一些文字< /消息> ;


-

问候,

DennisJDMyrén

奥斯陆Kodebureau

"DennisMyrén" <德**** @ oslokb.no>在消息中写道

news:tz ******************* @ news2.e.nsc.no ...

我认为你的评论应该是
<! - Title - >
而不是
< - Title - >

- -
问候,
DennisJDMyrén
Oslo Kodebureau
msuk < MS ** @ discussions.microsoft.com>在消息中写道
新闻:41 ********************************** @ microsof t.com。 ..



由于某些原因,我没有得到漂亮的树结构我在做什么
错误。


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("< / lt; / T1> \ r");

Response.Write(xml);

浏览器中的显示如下:

< - 标题 - >一些文字

Nicholas Paldino [.NET / C#MVP]"写道:

麝香,

基本上,你的XML格式不正确,所以浏览器有问题显示它。默认情况下,浏览器将样式表应用于
XML文档,以便使用漂亮的树结构显示它,您可以使用
习惯

来修复错误。
修复错误在XML中返回,它应该可以正常工作。

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP] - mv*@spam.guard.caspershouse.com

" msuk" < MS ** @ discussions.microsoft.com>在消息中写道
新闻:9A ********************************** @ microsof t.com。 ..
>全部,
>
>我有一个格式良好的XML块存储在C#字符串类型


I>只是想在浏览器中使用Response.Write显示它


但是>当我
>试试这个我收到以下错误:
>
>无法显示XML页面
>无法使用XSL样式表查看XML输入。请更正


错误和>然后单击刷新按钮,或稍后再试。
>
>

------------------- -------------------------------------------------- -----
------>
>在prolog之外不能有DOCTYPE声明。错误处理>资源''http://localhost/App1/WebForm1.asp ...
>
> <!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN" >
> ---------- ^
>
>




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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"msuk" <ms**@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...

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



I think your comment should be
<!-- Title -->
rather than
<-- Title -->
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"msuk" <ms**@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...

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:

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]
- mv*@spam.guard.caspershouse.com

"msuk" <ms**@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...

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" <de****@oslokb.no> wrote in message
news:tz*******************@news2.e.nsc.no...

I think your comment should be
<!-- Title -->
rather than
<-- Title -->
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"msuk" <ms**@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...

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:

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]
- mv*@spam.guard.caspershouse.com

"msuk" <ms**@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
> 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" >
> ----------^
>
>




这篇关于Response.Write表示XML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆