473,804 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use IE to display XML dynamically in an WinForm?

Hi,
I want to use the Webbrowser Control (the Internet Explorer Control) to
display an XML-structure within a C# WinForm.
The way the IE displays a XML-file in its native form is exactly what I need
(as tree structure with plus/minus).

This works great as long as I load the XML to display from a file with the
Navigate2-method of the control.

But my XML comes not from a file but is created dynamically during runtime.
When I feed the document-object of the IE-control with my generated XML,
unfortunately the IE control displays my XML as plain text and not in
XML-mode.

Does anyone know how to tell the IE with C# that the given string has to be
displayed as a XML document?

Any help appreciated,
Winston
Nov 15 '05 #1
7 2742
Winston,

There is an easy way, and a a few hard ways to do this. The easy way would be to save your XML to a temporary file and then navigate to that file.

The first hard way would be to define the IPersistMemory interface in your code. This is a COM interface that is part of the persistence framework that COM exposed. It allows you to load content from an area in memory. If you get this interface, then you can cast the HTML document to this interface and then call the Load method. Content type is determined by "sniffing" the content, as opposed to headers from a server.

The definitive way would be to create an implementation of the IMoniker interface and then control the information that is accessed by the HTML document when loading. With the implementation of IMoniker, you can control what the HTML document gets, so you can set the content type of the document to "text/xml" explicitly, which will trigger the display that you wish. For this, you would have to define the IMoniker and IPersistMoniker interfaces.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(d0t)paldin o=At-exisconsulting' dot|com

On Mon, 6 Oct 2003 11:36:59 +0200, Winston <wi***********@ gmx.net> wrote:
Hi,
I want to use the Webbrowser Control (the Internet Explorer Control) to
display an XML-structure within a C# WinForm.
The way the IE displays a XML-file in its native form is exactly what I need
(as tree structure with plus/minus).

This works great as long as I load the XML to display from a file with the
Navigate2-method of the control.

But my XML comes not from a file but is created dynamically during runtime.
When I feed the document-object of the IE-control with my generated XML,
unfortunately the IE control displays my XML as plain text and not in
XML-mode.

Does anyone know how to tell the IE with C# that the given string has to be
displayed as a XML document?

Any help appreciated,
Winston

Nov 15 '05 #2
Alternatively transform the source xml using IE's default stylesheet and
then use your current method to display the result. Default stylesheet at:
res://msxml3.dll/DEFAULTSS.xsl
--

Joe

"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote
in message news:op******** ******@msnews.m icrosoft.com...
Winston,

There is an easy way, and a a few hard ways to do this. The easy way would be to save your XML to a temporary file and then navigate to that
file.
The first hard way would be to define the IPersistMemory interface in your code. This is a COM interface that is part of the persistence framework
that COM exposed. It allows you to load content from an area in memory. If
you get this interface, then you can cast the HTML document to this
interface and then call the Load method. Content type is determined by
"sniffing" the content, as opposed to headers from a server.
The definitive way would be to create an implementation of the IMoniker interface and then control the information that is accessed by the HTML
document when loading. With the implementation of IMoniker, you can control
what the HTML document gets, so you can set the content type of the document
to "text/xml" explicitly, which will trigger the display that you wish. For
this, you would have to define the IMoniker and IPersistMoniker interfaces.
Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(d0t)paldin o=At-exisconsulting' dot|com

On Mon, 6 Oct 2003 11:36:59 +0200, Winston <wi***********@ gmx.net> wrote:
Hi,
I want to use the Webbrowser Control (the Internet Explorer Control) to
display an XML-structure within a C# WinForm.
The way the IE displays a XML-file in its native form is exactly what I need (as tree structure with plus/minus).

This works great as long as I load the XML to display from a file with the Navigate2-method of the control.

But my XML comes not from a file but is created dynamically during runtime. When I feed the document-object of the IE-control with my generated XML,
unfortunately the IE control displays my XML as plain text and not in
XML-mode.

Does anyone know how to tell the IE with C# that the given string has to be displayed as a XML document?

Any help appreciated,
Winston


Nov 15 '05 #3
Hi Nicholas,
that sounds very good. I like to try the way with the IPersistMemory
interface but I don't know which reference I have to add in my project to
get access to that interface.
Can you help?

Winston

"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote
in message news:op******** ******@msnews.m icrosoft.com...
Winston,

There is an easy way, and a a few hard ways to do this. The easy way would be to save your XML to a temporary file and then navigate to that
file.
The first hard way would be to define the IPersistMemory interface in your code. This is a COM interface that is part of the persistence framework
that COM exposed. It allows you to load content from an area in memory. If
you get this interface, then you can cast the HTML document to this
interface and then call the Load method. Content type is determined by
"sniffing" the content, as opposed to headers from a server.
The definitive way would be to create an implementation of the IMoniker interface and then control the information that is accessed by the HTML
document when loading. With the implementation of IMoniker, you can control
what the HTML document gets, so you can set the content type of the document
to "text/xml" explicitly, which will trigger the display that you wish. For
this, you would have to define the IMoniker and IPersistMoniker interfaces.
Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(d0t)paldin o=At-exisconsulting' dot|com

On Mon, 6 Oct 2003 11:36:59 +0200, Winston <wi***********@ gmx.net> wrote:
Hi,
I want to use the Webbrowser Control (the Internet Explorer Control) to
display an XML-structure within a C# WinForm.
The way the IE displays a XML-file in its native form is exactly what I need (as tree structure with plus/minus).

This works great as long as I load the XML to display from a file with the Navigate2-method of the control.

But my XML comes not from a file but is created dynamically during runtime. When I feed the document-object of the IE-control with my generated XML,
unfortunately the IE control displays my XML as plain text and not in
XML-mode.

Does anyone know how to tell the IE with C# that the given string has to be displayed as a XML document?

Any help appreciated,
Winston


Nov 15 '05 #4
On Mon, 6 Oct 2003 11:36:59 +0200, "Winston" <wi***********@ gmx.net>
wrote:
Hi,
I want to use the Webbrowser Control (the Internet Explorer Control) to
display an XML-structure within a C# WinForm.
The way the IE displays a XML-file in its native form is exactly what I need
(as tree structure with plus/minus).

This works great as long as I load the XML to display from a file with the
Navigate2-method of the control.

But my XML comes not from a file but is created dynamically during runtime.
When I feed the document-object of the IE-control with my generated XML,
unfortunatel y the IE control displays my XML as plain text and not in
XML-mode.

Does anyone know how to tell the IE with C# that the given string has to be
displayed as a XML document?


A quick and dirty way to do this is to temporarily persist your XML to
file, then load it from the file into your reader.

I do not know if there's a more elegant solution.

Nov 15 '05 #5
I solved it with your help and a little workaround.
Loading res://msxml3.dll/DEFAULTSS.xsl into my XMLDocument-Object didn't
work. I guess that those res:// files can only be read by the IE itself.
I found a slightly modified version of this Default-XSL at
http://www.biglist.com/lists/xsl-lis.../msg00769.html.
After fixing some typing errors I saved it into a file.
Now I load that XSL from disk, and transform my XML-string with this XSL
into HTML.
When I feed this into the IE-control it looks like the way the IE does it.

Thanks for your help,
Winston

"Joe Fawcett" <jo********@hot mail.com> wrote in message
news:Oh******** *****@TK2MSFTNG P09.phx.gbl...
Alternatively transform the source xml using IE's default stylesheet and
then use your current method to display the result. Default stylesheet at:
res://msxml3.dll/DEFAULTSS.xsl
--

Joe

"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote in message news:op******** ******@msnews.m icrosoft.com...
Winston,

There is an easy way, and a a few hard ways to do this. The easy way would be to save your XML to a temporary file and then navigate to that
file.

The first hard way would be to define the IPersistMemory interface in your code. This is a COM interface that is part of the persistence framework
that COM exposed. It allows you to load content from an area in memory. If you get this interface, then you can cast the HTML document to this
interface and then call the Load method. Content type is determined by
"sniffing" the content, as opposed to headers from a server.

The definitive way would be to create an implementation of the IMoniker interface and then control the information that is accessed by the HTML
document when loading. With the implementation of IMoniker, you can

control what the HTML document gets, so you can set the content type of the document to "text/xml" explicitly, which will trigger the display that you wish. For this, you would have to define the IMoniker and IPersistMoniker interfaces.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(d0t)paldin o=At-exisconsulting' dot|com

On Mon, 6 Oct 2003 11:36:59 +0200, Winston <wi***********@ gmx.net> wrote:
Hi,
I want to use the Webbrowser Control (the Internet Explorer Control) to display an XML-structure within a C# WinForm.
The way the IE displays a XML-file in its native form is exactly what I need (as tree structure with plus/minus).

This works great as long as I load the XML to display from a file with the Navigate2-method of the control.

But my XML comes not from a file but is created dynamically during runtime. When I feed the document-object of the IE-control with my generated
XML, unfortunately the IE control displays my XML as plain text and not in
XML-mode.

Does anyone know how to tell the IE with C# that the given string has
to be displayed as a XML document?

Any help appreciated,
Winston



Nov 15 '05 #6
"Winston" <wi***********@ gmx.net> wrote in message news:ur******** ******@tk2msftn gp13.phx.gbl...
I solved it with your help and a little workaround.
Loading res://msxml3.dll/DEFAULTSS.xsl into my XMLDocument-Object didn't
work. I guess that those res:// files can only be read by the IE itself.
I found a slightly modified version of this Default-XSL at
http://www.biglist.com/lists/xsl-lis.../msg00769.html.
After fixing some typing errors I saved it into a file.
Now I load that XSL from disk, and transform my XML-string with this XSL
into HTML.
When I feed this into the IE-control it looks like the way the IE does it.

Thanks for your help,
Winston

This transformation produces a display of non-well-formed xml in the
following two general cases:

1. The original xml document contains namespace declarations. In
this case
there are no namespace declarations displayed.

2. The original document contains (correctly) escaped ampersand. In
this case
unescaped ampersand is displayed.
The stylesheets used by the XPath Visualizer (for IE and for Mozilla)
do not have these flaws.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Nov 15 '05 #7
http://msdn.microsoft.com/library/de...th_hn_2uck.asp

--

Joe

"Winston" <wi***********@ gmx.net> wrote in message
news:ur******** ******@tk2msftn gp13.phx.gbl...
I solved it with your help and a little workaround.
Loading res://msxml3.dll/DEFAULTSS.xsl into my XMLDocument-Object didn't
work. I guess that those res:// files can only be read by the IE itself.
I found a slightly modified version of this Default-XSL at
http://www.biglist.com/lists/xsl-lis.../msg00769.html.
After fixing some typing errors I saved it into a file.
Now I load that XSL from disk, and transform my XML-string with this XSL
into HTML.
When I feed this into the IE-control it looks like the way the IE does it.

Thanks for your help,
Winston

"Joe Fawcett" <jo********@hot mail.com> wrote in message
news:Oh******** *****@TK2MSFTNG P09.phx.gbl...
Alternatively transform the source xml using IE's default stylesheet and
then use your current method to display the result. Default stylesheet at:
res://msxml3.dll/DEFAULTSS.xsl
--

Joe

"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote
in message news:op******** ******@msnews.m icrosoft.com...
Winston,

There is an easy way, and a a few hard ways to do this. The easy way

would be to save your XML to a temporary file and then navigate to that
file.

The first hard way would be to define the IPersistMemory interface in your
code. This is a COM interface that is part of the persistence framework
that COM exposed. It allows you to load content from an area in memory.

If
you get this interface, then you can cast the HTML document to this
interface and then call the Load method. Content type is determined by
"sniffing" the content, as opposed to headers from a server.

The definitive way would be to create an implementation of the IMoniker interface and then control the information that is accessed by the HTML
document when loading. With the implementation of IMoniker, you can

control
what the HTML document gets, so you can set the content type of the

document
to "text/xml" explicitly, which will trigger the display that you wish.

For
this, you would have to define the IMoniker and IPersistMoniker

interfaces.
Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(d0t)paldin o=At-exisconsulting' dot|com

On Mon, 6 Oct 2003 11:36:59 +0200, Winston <wi***********@ gmx.net> wrote:
> Hi,
> I want to use the Webbrowser Control (the Internet Explorer Control) to > display an XML-structure within a C# WinForm.
> The way the IE displays a XML-file in its native form is exactly
what I
need
> (as tree structure with plus/minus).
>
> This works great as long as I load the XML to display from a file
with the
> Navigate2-method of the control.
>
> But my XML comes not from a file but is created dynamically during runtime.
> When I feed the document-object of the IE-control with my generated

XML, > unfortunately the IE control displays my XML as plain text and not

in > XML-mode.
>
> Does anyone know how to tell the IE with C# that the given string

has to
be
> displayed as a XML document?
>
> Any help appreciated,
> Winston
>
>




Nov 15 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3045
by: ram | last post by:
I have a user control uc (with a dropdownlist uc_dd) that I dynamically add to a pane on a button_click. this pane is hosted on the winform. now when I add two instances of the user control (uc_dd1, uc_dd2), and change the selected item in the dropdown uc_dd1, the selected item in uc_dd2 also changes. any ideas? thank you!
7
13993
by: Winston | last post by:
Hi, I want to use the Webbrowser Control (the Internet Explorer Control) to display an XML-structure within a C# WinForm. The way the IE displays a XML-file in its native form is exactly what I need (as tree structure with plus/minus). This works great as long as I load the XML to display from a file with the Navigate2-method of the control. But my XML comes not from a file but is created dynamically during runtime.
7
2486
by: John | last post by:
Hi, Is there any control (free) that has same functionality as IE to display the XML document without having to create a physical file? if using Webbrowser control (ActiveX control) I have to create a xml file and then use .Navigate(url) ... Thanks!
6
1948
by: Chris | last post by:
I have a winform base class in which I dynamically set a web reference Url: myService.Url = <WebServer> + "MyService.asmx"; where <WebServer> is pulled from my App.config file. There is no problem working with this base class and the solution compiles and runs fine. However, I am unable to display any descendant forms in design mode in VS.NET 2003. I get a message indicating that:
0
1068
by: nobody | last post by:
I am running Microsoft's example of a windows form in aspx. http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/default.aspx The only way I can get the example to run is by opening up the permissions in the .Net Configuration 1.1. Right now I have defined a custom Code Group under LocalIntranet_Zone with FullTrust based on a Site or URL. The appp works with this permission set. If I try a strong name with a custom permission set...
3
1713
by: VB Programmer | last post by:
I have created a custom control in vb.net. How do I show 10 of them (vertical stack) on a new form when it loads? Thanks!
2
1488
by: sobmir | last post by:
A I'm new to c# and I came from c++ also. I want to create dynamicaly winform to get some data. I create a array of object as a description of variable which I want to get. I pass this array to a function which build a form, show the edit fields and return changed values. Changed values are stored in my array of objects but these original values are not changed. Short code snipet ( this is working) // ---- c# ---- struct desc {
6
1532
by: crazyjh | last post by:
hello i want to add some controls in according of the time. but when the time change, i call the method again to add controls again,No effect! i think maybe i should unload the controls adding before,how can i unload it?? pls help me,thanks
2
7055
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
5
4988
by: Andrus | last post by:
I have database containing translations. I'm creating VS 2005 WinForms application which should use this database to translate menu items to user language. I replaced lines in myform.designer.cs like Text = "File"; to call my translating routine
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.