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.