I know compact framework doesn't support XslTranform, but is ther any way that you can work around this if you want to transform a XML-document with a XSL sheet?
Transform XML with XSL in compact framework (c#)
Collapse
X
-
-
Thanks, but you cant use XslTransform in compact framework :-(Originally posted by sani723Comment
-
You can use MSXML DOM object, by importing the type library or through Reflection.
See these 2 C# examples.
To apply the XSL template over XML use the transformNode() method of the DOM object.
For reference, I give you a JavaScript example:
[html]<PRE nd="52"><html>
<body>
<script type="text/javascript">
// Load XML
var xml = new ActiveXObject(" Microsoft.XMLDO M")
xml.async = false
xml.load("cdcat alog.xml")
// Load XSL
var xsl = new ActiveXObject(" Microsoft.XMLDO M")
xsl.async = false
xsl.load("cdcat alog.xsl")
// Transform
document.write( xml.transformNo de(xsl))
</script>
</body>
</html>
</PRE>[/html]
You can use the version existing on your system:
MSXML2.DOMDocum ent.3.0,
MSXML2.DOMDocum ent.4.0 or
Microsoft.XMLDO M
If not sure what version you have, run Start/Run/regedit, and search for it.Comment
-
A simpler solution to use the XML DOM object:
From Project/Add Reference/COM add a reference to Microsoft XML v4.0.
Add this line in code:
Then you can instantiate a DOM object, like:Code:using MSXML2;
When using the doc object you will see listed all its methods:Code:MSXML2.DOMDocument40 doc = new DOMDocument40Class();
doc.load, doc.loadXML, doc.transformNo de....
I hope this helps.Comment
-
-
It seems that I took out my victory a little to early. I tried to add the dll-file like you said.
"From Project/Add Reference/COM add a reference to Microsoft XML v4.0."
However I didn't have a section named COM. So i downloaded msxml4.dll and tried to add it, but i didn't work. So i downloaded msxml3.dll instead and it worked fine.
Now I wrote
and thenCode:using MSXML2;
Code:MSXML2.DOMDocument30 doc = new DOMDocument30Class();
I get a COMException and the following description:
COM object with CLSID '{F5078F32-C551-11D3-89B9-0000F81FE221}' cannot be created due to the following error: 0x80040154.
Thanks in advance!Comment
-
Did you register the dll?
If not, try to run "regsvr32 msxml3.dll" within Start/Run.
Or install the MSXML kit.Comment
-
I'm sorry about that strange behavior.
However, keep the contact here.
Regarding the compact framework, try also to post any questions on .Net forum.
Thanks,
Dorin.Comment
-
I want convert the xml file to html file.I have xml file in \\abc.xml and xls file is in D:\abc.xsl can u tell the code to get abc.html after the fallowd line.
MSXML2.DOMDocum ent40 doc = new DOMDocument40Cl ass();
Regardds,
koti.
Originally posted by dorinbogdanI'm sorry about that strange behavior.
However, keep the contact here.
Regarding the compact framework, try also to post any questions on .Net forum.
Thanks,
Dorin.Comment
Comment