Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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



Reply With Quote
  #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)
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:30 PM.


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