XML document must have a top level element

I am getting this error when transforming an xml document using an xsl. I have tested that the xsl works in xmlSPY and everything works fine. Both my original xml and the output xml have top level elements (can these have attributes?).

My asp code is:

Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument")

set xslDoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocument")
xslDoc.async = false

set xslTemplate = Server.CreateObject("Msxml2.XSLTemplate")
' Setting the actual XSL document in the template
xslTemplate.stylesheet = xslDoc
' Compile your stylesheet into a processor
set xslProc = xslTemplate.createProcessor()
xslProc.addParameter "div", "E"

xslProc.input = xmlDoc  ' The xml input here is actually the xml you want to transform
xslProc.transform()  ' Do the transformation

Any help please?


What error?

sorry - the thread title:

XML document must have a top level element.

Can you show the XML file?

If i do:

Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument")

Set xslDoc=Server.CreateObject("MSXML2.DOMDocument")
xslDoc.async = false

str = xmlDoc.transformNode(xslDoc)

everything works fine, but i need to pass some params to the xsl.

The xml starts:

<?xml version="1.0" encoding="iso-8859-1"?>
		<perfStats upToMonth="Jul" financialYear="2006-07">
			<Division id="E">
				<stat type="1">

SO is it litterally asking you to add <coolStats> above your perfStats element?

Sounds like it to me, with no attributes or anything, along with an equally closed </coolStats>

perfStats is my root element! Root elements can have atrtributes, but must have no siblings - which it doesn’t.

sorted it - what a fool!!!1

I forgot to response.write my transform output!! hence no top level element!!

cheers for your help :blush: