怎样将一个XML转换格式为另一个XML(用XSL)
如:
<?xml version = '1.0 ' encoding = 'UTF-8 '?>
<ROOT>
<Book>
<name> XML </name>
<price> 20 </price>
</Book>
<ROOT>
目标格式:
<?xml version = '1.0 ' encoding = 'UTF-8 '?>
<Books>
<Book name= "XML " price= "20 "/>
<Books>
[解决办法]
<%
Set xslt = CreateObject( "Msxml2.XSLTemplate ")
Set xslDoc = CreateObject( "Msxml2.FreeThreadedDOMDocument ")
xslDoc.async = False
xslDoc.resolveExternals = False
xslDoc.Load Server.MapPath( "test0701.xsl ")
If (xslDoc.parseError.errorCode <> 0) Then
Set myErr = xslDoc.parseError
Response.Write "You have error " & myErr.reason
Else
Set xslt.stylesheet = xslDoc
Set xmlDoc = CreateObject( "Msxml2.DOMDocument ")
xmlDoc.async = False
xmlDoc.resolveExternals = False
xmlDoc.Load Server.MapPath( "test0701.xml ")
If (xmlDoc.parseError.errorCode <> 0) Then
Set myErr = xmlDoc.parseError
Response.Write "You have error " & myErr.reason
Else
Set xslProc = xslt.createProcessor()
xslProc.input = xmlDoc
xslProc.Transform
Response.Write Server.HTMLEncode(xslProc.output)
End If
End If
%>