Subject: Help making a doc using XML
Posted By: topshed Post Date: 1/27/2006 10:47:14 PM
I am attempting to write a file using an XML type script to do so, its working sort of but I have one small problem

The script I am using is :-

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
DIM sPath
Dim sql
Dim strSearch
strSearch = "A-2"
'Just check it's there !
response.write "strSearch value =  "
response.write strSearch

Set conn = server.createobject("adodb.connection")
sPath = Server.MapPath("../steam.mdb")
    cn= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & sPath
Set rs = Server.CreateObject("ADODB.Recordset")

' Query the lner table from the steam db
sql = "SELECT * FROM lner "_
& "ORDER BY  lner.br_no "

' Execute the sql
rs.Open sql, cn

' Move to the first record
rs.MoveFirst

' Name for the ouput document
file_being_created= "/ttp_files/content.js"

' create a file system object
set fso = createobject("scripting.filesystemobject")

' create the text file - true will overwrite any previous files
' Writes the db output to a .xml file in the same directory
Set act = fso.CreateTextFile(server.mappath(file_being_created), true)

' All non repetitive stuff on top goes here
act.WriteLine("var TABLE_CONTENT = [")
act.WriteLine("['Class','Pre', 'BR No.', 'LNER No.', 'cme','code','last-shed' ],")

'Loop to output all the query results to the document
'limit the output to 19 while no search / filter present

do while counter < 19
' counter to give each record a sequential listing
counter=counter+1
'write a line

'This is where I have the problem###########################

act.WriteLine("[" & rs("pregroup") & "," & rs("br_no") & "," & rs("other_no") & "," & rs("cme") & "," & rs("code") & "," & rs("last_shed") & "]," )

' Just that line #############################################

' move to the next record
rs.movenext
loop
' non repetitive last line goes here
act.WriteLine("];")

' close the object (xml)
act.close
' Writes a link to the newly created xml document in the browser
response.write "<a href='/ttp_files/content.js'>content</a>(.js) has been created <br>"
response.write "on " & now() & "<br>"
%>

which produces output like this:-

TABLE_CONTENT = [
['Class','Pre', 'BR No.', 'LNER No.', 'cme','code','last-shed' ],
[1729,,1729,"W.Worsdell","MID","Middlesborough"],
[1708,,1708,W.Worsdell,MID,Middlesborough ],
[0,0,2523,M.Stirling,IMM,Immingham ],
[0,0,1862,T.W.Worsdell,, ],
[0,0,1835,T.W.Worsdell,, ],
];

Which does what I want except that I need pairs of inverted comma's round the last 3 fields which are Text  so a line reads
[0,0,2523,"M.Stirling","IMM","Immingham" ],


But I cannot get the syntax correct

Please help

Topshed



Reply By: joefawcett Reply Date: 1/28/2006 6:03:53 AM
Not quite sure what this has to do with XML but if you want quotes around a value you need something like:

act.WriteLine("[""" & rs("pregroup") & """,""" & rs("br_no" & """, """ & .....


--

Joe (Microsoft MVP - XML)
Reply By: topshed Reply Date: 1/28/2006 7:05:45 PM
Hi Joe,

Thank you so much for that, I used an xml creating script, modified, to achieve a purpose,
but I could not get the syntax correct to put " " around text fields which I needed to parse
to a JavaScript in ASP

Regards

topshed

Go to topic 38705

Return to index page 383
Return to index page 382
Return to index page 381
Return to index page 380
Return to index page 379
Return to index page 378
Return to index page 377
Return to index page 376
Return to index page 375
Return to index page 374