Added the XML document display interface (C #) for the webbrowser control #)

Source: Internet
Author: User
Tags xslt

Here is a tip for webbrowser control to demonstrate an XML file. The materials to be prepared include:
A. Style File defaultss. XSLT, which is the file used by IE to convert XML to XHTML by default.
B. For a test project, you must add a webbrowser control object to the project.

Follow these steps to complete this experiment:
1. Add defass ss. xslt to the test project.
2. Set defaultss. XSLT build action = embedded resource in the attribute.
3. Expand a class named webbrowserex from webbrowser

Code
ClassWebbrowserex: webbrowser
4. Load defaultss. XSLT from the resource to webbrowser Code

code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/

--> Assembly ASMB = system. reflection. assembly. getexecutingassembly ();
stream S = ASMB. getmanifestresourcestream (ASMB. getname (). name + " . " + m_effectfile );
xmlreader XR = xmlreader. create (s);

5. Finally, use the xslcompiledtransform transform method to convert XML to XHTML.

Below is the complete Code Code
Class Webbrowserex: webbrowser
{
Private   String M_effectfile =   " Defaultss. XSLT " ;
Public Xmldocument documentxml
{
Set
{
Assembly ASMB = System. reflection. Assembly. getexecutingassembly ();
Stream s = ASMB. getmanifestresourcestream (ASMB. getname (). Name +   " . "   + M_effectfile );
Xmlreader XR = Xmlreader. Create (s );
Xslcompiledtransform xct =   New Extends compiledtransform ();
Xct. Load (xr );

Stringbuilder sb= NewStringbuilder ();
Xmlwriter XW=Xmlwriter. Create (SB );
Xct. Transform (value, XW );

This. Documenttext=SB. tostring ();
}
}

Public StringXmlstyletranferfile
{
Set{M_effectfile=Value ;}
}
}

 
Defaultss. XSLT download.
Disclaimer: this file is obtained from the Internet and does not guarantee the validity of the file copyright. Please do not use it in commercial software.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.