Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic XML creation

Status
Not open for further replies.

bont

Programmer
Sep 7, 2000
200
US
I am trying the following:
Code:
<%@ Language=VBScript %>
<%
Dim objTemplate, objProcessor, strSortField, strGameNumber, objXML, objXSL, strHTML, aSTR
	Set objXML = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
	Set objXSL = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
	set xmlParams = Server.CreateObject("Msxml2.DOMDocument.4.0") 
	objXML.async = False
	
	
	if cstr(Request.QueryString("Key")) = "all" or cstr(Request.QueryString("Key")) = "" then
		objXML.Load Server.MapPath("DVD_Cats.xml")
	else
		objXSL.loadXML("<cats TS=""""><cat name=""DVD_Cat_S.xml"" k=""S"" /></cats>")
	end if
	
	
	objXSL.async = False
	objXSL.Load Server.MapPath("DVD_All_Temp.xsl")
	Set objTemplate = Server.CreateObject("MSXML2.XSLTemplate.3.0")
	Set objTemplate.stylesheet = objXSL
	Set objProcessor = objTemplate.createProcessor
	objProcessor.input = objXML
	call objProcessor.addParameter("Key", cstr(Request.QueryString("Key")))	
	objProcessor.Transform
strHTML = objProcessor.output
Response.write strHTML
%>

It works fine, except for:
Code:
	else
		objXSL.loadXML("<cats TS=""""><cat name=""DVD_Cat_S.xml"" k=""S"" /></cats>")
	end if

How can I load an XML fragment, such as this, so that I can pass it to the transform. It is important that this be recognized as an individual document for the rest to work.
 
OK, now I found a typo, but I still can't get this to work:
Code:
<%@ Language=VBScript %>
<%
Dim objTemplate, objProcessor, strSortField, strGameNumber, objXML, objXSL, strHTML, aSTR, Root
	Set objXML = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
	Set objXSL = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
	objXML.async = False
	
	
	if cstr(Request.QueryString("Key")) = "all" or cstr(Request.QueryString("Key")) = "" then
		objXML.Load Server.MapPath("DVD_Cats.xml")
	else
		call objXML.loadXML("<cats TS=""""><cat name=""DVD_Cat_S.xml"" k=""S"" /><cat name=""DVD_Cat_S.xml"" k=""S"" /></cats>")
	end if
	
	Set Root = objXML.documentElement 
	response.write(Root.xml)
	
'	objXSL.async = False
'	objXSL.Load Server.MapPath("DVD_All_Temp.xsl")
'	Set objTemplate = Server.CreateObject("MSXML2.XSLTemplate.3.0")
'	Set objTemplate.stylesheet = objXSL
'	Set objProcessor = objTemplate.createProcessor
'	objProcessor.input = objXML
'	call objProcessor.addParameter("Key", cstr(Request.QueryString("Key")))	
'	objProcessor.Transform
'strHTML = objProcessor.output
'Response.write strHTML
%>

The above code will pass the XML data; however, when I uncomment out the bottom portion and comment out the first write item, I can't get it to be passed through transform without an error.

Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top