Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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
  #1 (permalink)  
Old January 27th, 2006, 11:47 PM
Authorized User
 
Join Date: Sep 2003
Location: Melbourne, Victoria, Australia.
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help making a doc using XML

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_creat ed), 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



  #2 (permalink)  
Old January 28th, 2006, 07:03 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not quite sure what this has to do with XML but if you want quotes around a value you need something like:
Code:
act.WriteLine("[""" & rs("pregroup") & """,""" & rs("br_no" & """, """ & .....
--

Joe (Microsoft MVP - XML)
  #3 (permalink)  
Old January 28th, 2006, 08:05 PM
Authorized User
 
Join Date: Sep 2003
Location: Melbourne, Victoria, Australia.
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating XML doc ; writing string(xml format) into KamalRaturi XML 5 May 28th, 2008 05:51 AM
Reading XML doc into dataset ankitd25 XML 4 April 29th, 2008 02:37 AM
Help in making a FLAT xml to a structured xml shlomi XSLT 0 July 19th, 2007 07:58 AM
Converting XML to XML (making element mandatory) boondocksaint20 XSLT 8 April 28th, 2006 10:54 AM
whole database to XML doc beyondforsaken VB How-To 4 June 11th, 2003 08:12 PM





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