Webbrowser & XML

L

Lee

Hi,

I am using the WebBrowser control included with VS2005 to view XML files,
and they are being displayed correctly as far as I can tell.

The problem I am having is saving these XML files to disk.

If I try to save the contents of the WebBrowser.DocumentText to disk, the
resulting file contains HTML and script that I don't want. Is there any way
I can save the actual XML document to disk from the WebBrowser control?

Many thanks.

Lee.
 
C

Cyril Gupta

Hello Lee,

This is just a hunch, but a HTTPRequestDocument should retrieve pure XML and
not the HTML code that then IE adds while rendering.

Regards
Cyril Gupta
 
T

Tim Anderson

I am using the WebBrowser control included with VS2005 to view XML files,
and they are being displayed correctly as far as I can tell.
If I try to save the contents of the WebBrowser.DocumentText to disk, the
resulting file contains HTML and script that I don't want. Is there any
way
I can save the actual XML document to disk from the WebBrowser control?

Can you clarify what you want to do? Are you modifying the XML in any way?
If not, why is there any need to save from IE, as opposed to copying from
your original source?

That aside, what is interesting here is that if you load XML into a
WebBrowser, right-click and choose View Source, you get the original file.
Maybe it does it like this:

When IE displays XML, it applies a stylesheet to give you the pretty
hierarchical view. However, have a look here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebteam/html/webteam05072001.asp

and note this:

"Conveniently, as well as transforming your XML into a collapsible hierarchy
display, Internet Explorer also adds an XMLDocument expando property to the
document object that provides access to the original XML."

It looks like you can get at this through the DOM, or adapt the C++ code in
the article :)

Tim

Read my tech blog:
http://www.itwriting.com/blog
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top