XML and WebBrowser control

Right, basically this application I am building uses a WebBrowser control to download an XML file. No problems whatsoever, it displays it beautifully.

The problem I am having now is accessing the direct XML (without all the rendered IE HTML) from the web browser. Simply calling:

Dim xmlstuff As String = wb1.DocumentText

does not give me the pure XML, rather the rendered IE html.

I am using Visual Basic 2005 Express Edition, any support would be appreciated =)




Answer this question

XML and WebBrowser control

  • Chuck H

    In .NET Framework 2.0 is recommended to use XslCompiledTransform.



  • Roopesh Babu Valluru

    -Anton Lapounov wrote:

    Why don't you use the XmlDocument class

    XmlDocument doc = new XmlDocument();

    doc.Load("http://mysite.com/myfile.xml");

    Console.WriteLine(doc.OuterXml);

    Thanks,
    Anton

    yes, using XmlDocument.Load method is a more suitable ,comfortable way.

    but ,however you must using the WebControl, you must let the WebControl believe it is a HTML document not a XMLDoucmnet.

    you can change Content-Type to "text/HTML" or make the file extend filename to ".HTM".

    how ,you can you WebControl.DoumentText property to read the XML string.



  • pdxJaxon

    The WebBrowser control does not publish the XMLDocument and XSLDocument properties because Use of MSXML is Not Supported in .NET Applications.

    So since you are in control of how you load your WebControl you could first load the XML into an XmlDocument and transform it to HTML using XslTransform, then load the result into the WebControl. This is in fact how the XML editor works inside of Visual Studio 2005 when you click on "Show XSLT".


  • Meng CHew

    Does the web browser control give you access to the HTMLDocument

    If so then you need the HTMLDocument.XMLDocument property. That certainly worked in the COM version of the web browser control.



  • IHan

    Why don't you use the XmlDocument class

    XmlDocument doc = new XmlDocument();

    doc.Load("http://mysite.com/myfile.xml");

    Console.WriteLine(doc.OuterXml);

    Thanks,
    Anton


  • DonRajah

    There isn't an XMLDocument member to the .Document property, but there is a .Document HTMLDocument property.

  • XML and WebBrowser control