views:

52

answers:

1

Below is my xml

XML1

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<CATALOG>
  <CD>
    <TITLE>1</TITLE> 
    <ARTIST>Bob Dylan</ARTIST> 
    <COUNTRY>USA</COUNTRY>   
    <COMPANY>Columbia</COMPANY> 
    <PRICE>10.90</PRICE> 
    <YEAR>1985</YEAR> 
  </CD>
  <CD>
    <TITLE>2</TITLE> 
    <ARTIST>Bonnie Tyler</ARTIST> 
    <COUNTRY>UK</COUNTRY> 
    <COMPANY>CBS Records</COMPANY> 
    <PRICE>9.90</PRICE> 
    <YEAR>1988</YEAR> 
  </CD>
</CATALOG>

XML2

  <?xml version="1.0" encoding="ISO-8859-1" ?> 
<CATALOG>
  <CD>
  <TITLE>3</TITLE> 
    <ARTIST>Dolly Parton</ARTIST> 
    <COUNTRY>USA</COUNTRY> 
    <COMPANY>RCA</COMPANY> 
    <PRICE>9.90</PRICE> 
    <YEAR>1982</YEAR> 
  </CD>
</CATALOG>

i need output like this

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<CATALOG>
  <CD>
    <TITLE>1</TITLE> 
    <ARTIST>Bob Dylan</ARTIST> 
    <COUNTRY>USA</COUNTRY> 
    <COMPANY>Columbia</COMPANY> 
    <PRICE>10.90</PRICE> 
    <YEAR>1985</YEAR> 
  </CD>
  <CD>
    <TITLE>2</TITLE> 
    <ARTIST>Bonnie Tyler</ARTIST> 
    <COUNTRY>UK</COUNTRY> 
    <COMPANY>CBS Records</COMPANY> 
    <PRICE>9.90</PRICE> 
    <YEAR>1988</YEAR> 
  </CD>
  <CD>
    <TITLE>3</TITLE> 
    <ARTIST>Dolly Parton</ARTIST> 
    <COUNTRY>USA</COUNTRY> 
    <COMPANY>RCA</COMPANY> 
    <PRICE>9.90</PRICE> 
    <YEAR>1982</YEAR> 
  </CD>
</CATALOG> 

How i write this in classic asp ?

A: 

I recommend turning this question into an XSLT question. This means you need to get XSLT running on classic ASP. My notes from 2005 might help:

The main idea behind incorporating XML into ASP solutions (besides vacuous fashion trends labeled "cool") is to reduce dependency on Microsoft-specific components (while simultaneously being vendor-compliant). In keeping with this realistic goal, the first Microsoft-specific target is the ADO Recordset. The second major target is the use of ASP scripting languages to render HTML.

First target: the ADO Recordset. Replace the ADO Recordset with the ADO Stream in ADO 2.5 and above:

"HOWTO: Obtain an ADO Recordset from XML" http://support.microsoft.com/support/kb/articles/Q263/2/47.ASP

"Server-Side XML in ASP” http://www.15seconds.com/Issue/990527.htm

Second target: use XML/XSL to render HTML. This is based on the Microsoft.XMLDOM object.

"Separating Content from Presentation with Server-Side XML" http://msdn.microsoft.com/library/periodic/period99/xml.htm

"'DXML': Taking a TOC from XML to DHTML" http://msdn.microsoft.com/workshop/Author/dhtml/corner042699.asp

Here is a code sample in JScript from my archives:

<%@ LANGUAGE = JScript %>
<%
    // Set the source and style sheet locations here
    var sourceFile = Server.MapPath("simple.xml");
    var styleFile = Server.MapPath("simple.xsl");

    // Load the XML 
    var source = Server.CreateObject("Microsoft.XMLDOM");
    source.async = false;
    source.load(sourceFile);

    // Load the XSL
    var style = Server.CreateObject("Microsoft.XMLDOM");
    style.async = false;
    style.load(styleFile);

    source.transformNodeToObject(style, Response);
%>
rasx