Link to home
Start Free TrialLog in
Avatar of tahirjadoon
tahirjadoon

asked on

ASP & XML Document

I have XML and XSL documents stored in SQL Server 2000 field. On the asp page i will be getting these documents from the database and then displaying the content of the XML document according to the XSL on the asp page.

How can i do this?

Also after getting the documents from the database do i need to store these on the server as .XML and .XSL and then read through these or i can directly read from these document without saving these physically.

ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of af500
af500

exactly like that ;)
Avatar of tahirjadoon

ASKER

I have not tested this yet, as soon as i have tested it i'll post the result.
Can i pass XML as string rather than storing the files physically. If yes, then can i do some thing like:

xmlContent = recordset.fields("XML").value
xslContent = recordset.fields("XSL").value

or i have to use here ado stream to read the files from the recordset


and then

set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.loadXML(xmlContent)

set style = Server.CreateObject("Microsoft.XMLDOM")
style.async = false
style.load(xslContent)

Response.Write source.transformNode(style)
I seem to remember reading that the XML can be passed as a string....I'll see if I can find the reference.

FtB
Have you tried just passing the strings from the database to these two lines?

sourceFile = Server.MapPath("DataContent.xml")
styleFile = Server.MapPath("DataContent.xsl")

i.e.,

sourceFile = objRS("strXML")
styleFile = objRS("strXSL")
 

FtiB
I have checked it with the physical file and it works.

Have not checked it yet with passing the string directly from the recordset field.
You can use strings stored in a database instead of files.

All you need to change is how you load the XML DOM.

Instead of using

source.load "<file name>"

use:

source.loadXML <string value from database>
@deighc--

So what I said above will work, then?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
   
  sourceFile = objRS("strXML")
  styleFile = objRS("strXSL")

  set source = Server.CreateObject("Microsoft.XMLDOM")
  source.async = false
  source.load(sourceFile)
  set style = Server.CreateObject("Microsoft.XMLDOM")
  style.async = false
  style.load(styleFile)
  Response.Write source.transformNode(style)
%>

or is it necessary to change:

source.load(sourceFile)

to:

source.loadXML(sourceFile)


source.loadXML works

xmlContent = recordset.fields("XML").value
xslContent = recordset.fields("XSL").value

Thanks guys
Glad to have helped,

FtB