在WebBrowser控件中显示XML [英] Display XML in WebBrowser Control

查看:110
本文介绍了在WebBrowser控件中显示XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在WebBrowser控件中显示XML。我收到了一个

XML的数据源,我正在尝试将其注入控件。我没有成功

这样做。


我找到的唯一解决方案是将它写入临时文件然后使用

用于加载它的Navigate方法。由于控件能够从

磁盘加载它,我想找到一种方法来跳过保存/加载并注入。


谢谢,

Dave

解决方案




Webbert写道:
< blockquote class =post_quotes>
我试图在WebBrowser控件中显示XML。我收到了一个

XML的数据源,我正在尝试将其注入控件。我没有成功

这样做。


我找到的唯一解决方案是将它写入临时文件然后使用

用于加载它的Navigate方法。由于控件能够从

磁盘加载它,我想找到一种方法来跳过保存/加载并注入。



什么样的XML显示?你在找?在IE浏览器窗口中加载XML文档时,您可以获得的XML源代码树的可折叠非常好吗?
?这是通过使用MSXML的IE

应用的XSL样式表完成的。不幸的是,如果你有一个带有

标记的字符串,我不认为有可能获得

IE或WebBrowser控件。然而,你在.NET 2.0应用程序中可以做的是用.NET运行XSLT转换以将XML转换为HTML然后

设置控制。


-


Martin Honnen --- MVP XML
http://javaScript.FAQTs.com/


可折叠很好但是不需要。


你说...用.NET运行XSLT转换,将XML转换为

HTML。

我将用什么来进行转换?是否存在通用XSL?由于

我正在处理的数据不详,我不能很好地创建一个特定的

XSL。


谢谢,

Dave

" Martin Honnen"写道:


>


Webbert写道:


我试图在WebBrowser控件中显示XML。我收到了一个

XML的数据源,我正在尝试将其注入控件。我没有成功

这样做。


我找到的唯一解决方案是将它写入临时文件然后使用

用于加载它的Navigate方法。由于控件能够从

磁盘加载它,我想找到一种方法来跳过保存/加载并注入。



什么样的XML显示?你在找?在IE浏览器窗口中加载XML文档时,您可以获得的XML源代码树的可折叠非常好吗?
?这是通过使用MSXML的IE

应用的XSL样式表完成的。不幸的是,如果你有一个带有

标记的字符串,我不认为有可能获得

IE或WebBrowser控件。然而,你在.NET 2.0应用程序中可以做的是用.NET运行XSLT转换以将XML转换为HTML然后

设置控制。


-


Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


很抱歉如果你有一个带有标记的字符串,我不认为有可能获得IE或WebBrowser


控制来做到这一点。



经验证 - 有关详细信息,请参阅XPath Visualizer的代码。


另一条评论:defaultss.xsl不是用XSLT编写,我们知道。


干杯,

Dimitre Novatchev

" Martin Honnen" < ma ******* @ yahoo.dewrote in message

news:eN ************* @ TK2MSFTNGP06.phx.gbl ...


>


Webbert写道:


>我试图在WebBrowser控件中显示XML。我收到XML的数据源,并试图将其注入控件。我没有成功这样做。我找到的唯一解决方案是将其写入临时文件,然后使用Navigate方法加载它。由于控件能够从磁盘加载它,我想找到一种方法来跳过保存/加载并注入。



什么样的XML显示?你在找?当您在IE浏览器窗口中加载XML文档时,您获得的XML源代码树的可折叠相当可靠吗?这是通过IE使用MSXML应用

的XSL样式表完成的。不幸的是,如果你有一个带有标记的字符串,我不认为有可能获得IE或

WebBrowser控件来做到这一点。你在.NET 2.0应用程序中可以做的事情是,用.NET运行XSLT

转换,将XML转换为HTML,然后设置

控件的DocumentText属性。


-


Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/



I am trying to display XML in a WebBrowser Control. I receive a data feed of
XML and am trying to inject it into the control. I have not been successful
in doing so.

The only solution I have found is to write it to a temp file and then use
the Navigate method to load it. As the control is capable of loading it from
disk, I would like to find a way to skip the save/load and just inject.

Thanks,
Dave

解决方案



Webbert wrote:

I am trying to display XML in a WebBrowser Control. I receive a data feed of
XML and am trying to inject it into the control. I have not been successful
in doing so.

The only solution I have found is to write it to a temp file and then use
the Navigate method to load it. As the control is capable of loading it from
disk, I would like to find a way to skip the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document
in an IE browser window? That is done with an XSL stylesheet that IE
applies using MSXML. Unfortunately I don''t think it is possible to get
IE or the WebBrowser control to do that if you have a string with
markup. What you could do in a .NET 2.0 application however is to run
the XSLT transformation with .NET to transform the XML to HTML and then
set the DocumentText property of the control.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


The collapsable is nice but not required.

You said..."run the XSLT transformation with .NET to transform the XML to
HTML".
What would I used to do the transformation? Does a generic XSL exist? As
the data I am working on is not known, I can''t very well create a specific
XSL.

Thanks,
Dave
"Martin Honnen" wrote:

>

Webbert wrote:

I am trying to display XML in a WebBrowser Control. I receive a data feed of
XML and am trying to inject it into the control. I have not been successful
in doing so.

The only solution I have found is to write it to a temp file and then use
the Navigate method to load it. As the control is capable of loading it from
disk, I would like to find a way to skip the save/load and just inject.


What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document
in an IE browser window? That is done with an XSL stylesheet that IE
applies using MSXML. Unfortunately I don''t think it is possible to get
IE or the WebBrowser control to do that if you have a string with
markup. What you could do in a .NET 2.0 application however is to run
the XSLT transformation with .NET to transform the XML to HTML and then
set the DocumentText property of the control.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Unfortunately I don''t think it is possible to get IE or the WebBrowser

control to do that if you have a string with markup.

Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...

>

Webbert wrote:

>I am trying to display XML in a WebBrowser Control. I receive a data
feed of XML and am trying to inject it into the control. I have not been
successful in doing so. The only solution I have found is to write it to
a temp file and then use the Navigate method to load it. As the control
is capable of loading it from disk, I would like to find a way to skip
the save/load and just inject.


What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document in
an IE browser window? That is done with an XSL stylesheet that IE applies
using MSXML. Unfortunately I don''t think it is possible to get IE or the
WebBrowser control to do that if you have a string with markup. What you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set the
DocumentText property of the control.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/



这篇关于在WebBrowser控件中显示XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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