Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2003, 12:05 PM
Registered User
 
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP to XML

Hi,

I need to write an ASP that when called with

URL = ....../conversion.asp?amount=100&account=USD

returns a XML file that looks like

<?xml version = "1.0" standalone = "yes"?>
<NOK> i </NOK> '(i is the result of a currency conversion)

My attempt (short version) was

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>

<b><% ' declares variables .......

    n = Request.Item("amount") ' input1
    strCode = "'" & Request.Item("account") & "'" ' input2

    ' .......calls database using n and strCode to find

    i = CInt(Trim(rS.Fields(0)))

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set a = fso.CreateTextFile("NOK.xml", True)

    a.WriteLine("<?xml version=" & Chr(34) & "1.0" & Chr(34) & _
                    " standalone=" & Chr(34) & "yes" & Chr(34) & "?>")

    a.WriteLine(" <NOK>" & i & "</NOK>")

    a.Close

    response.Redirect("C:\NOK.xml")

    %></b>

</BODY>
</HTML>

this almost works and it indeed does create the file NOK.xml
in the c-directory, however the redirection gives the error
message:

" Cannot view XML input using style sheet. etc. "

can anyone help?

                                           ernst.



 
Old September 10th, 2003, 03:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You don't need to save an XML file to disk, you can just send XML directly to the browser instead, like this:
Code:
<%   ' do not output any HTML before this, instead tell the browser we're sending XML
    Response.ContentType = "text/xml"

    ' declares variables .......

    n = Request.Item("amount")                          ' input1
    strCode = "'" & Request.Item("account") & "'"       ' input2

    ' .......calls database using n and strCode to find

    i = CInt(Trim(rS.Fields(0)))
      
    Response.Write("<?xml version=""1.0"" standalone=""yes""?>")
    Response.Write("<NOK>")
    Response.Write(i)
    Response.Write("</NOK>")

    %>
 
Old September 10th, 2003, 09:24 AM
Registered User
 
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi pqtips,

Yes that works! Thank's a lot.

                  ernst.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Relational SQL Data to XML - Vet SQL/ASP - New XML JimiTheJett XML 1 December 4th, 2008 06:06 PM
post xml data from ASP.NET app to ASP app polekat Classic ASP Professional 2 January 31st, 2007 08:44 AM
xml invalid top level from ASP write XML(solution) g000we XML 0 August 9th, 2006 03:56 AM
asp xml Kabe XML 3 September 4th, 2003 02:53 AM
XML, XML Schema, JavaScript, ASP cyberjames2003 XML 0 June 4th, 2003 04:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.