Hello, I am trying to convert one XML format to another using XSL. For this I use TransformNodeToObject to convert the source XML to result XML, subsequently saving the result XML to disk. I am facing weird problems with TransformNodeToObject wherein the resultant XML is empty. I am aware about the issues of this API with not well-formed XMLs. So I checked the error code and error string after invoking the API. Surprisingly, it returns error code of '0' and empty error string! At the same time TransformNode API works well. Please someone help me. I'm pasting the xml, xsl files (both utf-8) and vbscript to do the conversion over here for your reference. Please someone advise what is happening here. BTW, I have got MS VS 2008 installed on my machine (Just for info, in case the new DLLs have bugs in them; and moreso because previously these things used to work at least the xml to html conversion). Thanks in advance. - Mandar XML Source (filename: school.xml) -------------------------------- <?xml version="1.0" encoding="utf-8"?> <school> <class> <student> <name>Name_1</name> <lastname>lastname_1</lastname> </student> </class> <student> <name>Name_2</name> <lastname>lastname_2</lastname> </student> <student> <name>Name_3</name> <lastname>lastname_3</lastname> </student> <student> <name>Name_4</name> <lastname>lastname_4</lastname> </student> <class> </class> <class> <student> <name>Name_5</name> <lastname>lastname_5</lastname> </student> <student> <name>Name_6</name> <lastname>lastname_6</lastname> </student> </class> </school> XSL file (filename: school_convt.xsl) ------------------------------------ <?xml version='1.0' encoding='utf-8' ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes" omit-xml-declaration="yes" encoding="utf-8" version="1.0"/> <xsl:template match="/"> <xsl:element name="City"> <xsl:for-each select="school/*"> <xsl:element name="{name()}"> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> </xsl:stylesheet> VBScript (filename: convert.vbs) -------------------------------- set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0") xmlDoc.async = false xmlDoc.load ("school.xml") set xslDoc = CreateObject("Msxml2.DOMDocument.6.0") xslDoc.async = false xslDoc.load ("school_convt.xsl") set xslResult = CreateObject("Msxml2.DOMDocument.6.0") xslResult.async = false xslResult.validateonparse = true xslDoc.transformNodeToObject xslDoc, xslResult xslResult.save("school_output.xml") msgbox xslResult.parseerror.reason msgbox xslResult.parseerror msgbox xmlDoc.transformnode (xslDoc)
A correction about above sample xsl file. Although I have written 'html' as value for 'xsl:output method' tag, I was actually using xml output method. It was just that I was playing around with different values to check if it helps ... that's how 'html' ended up there in that place. Thnx Mandar
win_cpp wrote: > xslDoc.transformNodeToObject xslDoc, xslResult ^^^^^^ You need xmlDoc.transformNodeToObject xsldoc, xslResult -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/