Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. 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 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 Display Modes
  #1 (permalink)  
Old January 4th, 2011, 04:27 AM
Registered User
 
Join Date: Jan 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert access data to xml

Hi,
I want to create a xml file from asp and access database.
I retreiving data from the database without any problem but i have to respect xml schema and i didn't succeed in.

Is someone can help me?

here the xml schema:
Code:
<photo image="images/01.jpg" bigimage = "images/big/01.jpg" target="_blank" lightboxinfo="Description for image 1" url="http://www.flashxml.net"><![CDATA[Hello]]></photo>
and here my asp code to generate xml:

Code:
<%
' Name of the access db being queried
accessdb="state_info" 

' Connection string to the access db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & "F:\inetpub\vhosts\comptoirdumatelot.fr\httpdocs\fpdb\al1234.mdb"

' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Query the states table from the state_info db
sql = "select pid,pname,pImage from products " 

' Execute the sql
rs.Open sql, cn

' Move to the first record
rs.MoveFirst

' Name for the ouput document 
file_being_created= "cat.xml"

' 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 xml on top goes here
act.WriteLine("<?xml version=""1.0"" encoding=""ISO-8859-1"" ?>")


act.WriteLine("<slideshow>")

'Loop to output all the query results to the xml document
do while not rs.eof

' counter to give each record a sequential listing
act.WriteLine("<photo image="""& rs("pImage") )
act.WriteLine("bigimage=""" & rs("pImage")&"")
act.WriteLine("lightboxinfo=" & rs("pname"))
act.WriteLine("url=" & rs("pIid"))

' move to the next record
rs.movenext
loop

' All non repetitive xml on bottom goes here
act.WriteLine("</slideshow>")

' close the object (xml)
act.close

' Writes a link to the newly created xml document in the browser
response.write "<a href='cat.xml'>cat</a> (.xml) has been created <br>"
response.write "on  " & now() & "<br>"
%>
thanks
Reply With Quote
  #2 (permalink)  
Old January 4th, 2011, 06:35 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Ummm...your XML isn't at all valid.

These lines:
Code:
act.WriteLine("<photo image="""& rs("pImage") )
act.WriteLine("bigimage=""" & rs("pImage")&"")
act.WriteLine("lightboxinfo=" & rs("pname"))
act.WriteLine("url=" & rs("pIid"))
would end up writing out something such as
Code:
<photo image="xyz.jpg
bigimage="big_xyz.jpg
lightboxinfo=xyz
url=www.foo.com
for each record. That doesn't BEGIN to look like valid XML.

Maybe you need to show us what your valid XML *should* look like and we can help you create it from ASP??
Reply With Quote
  #3 (permalink)  
Old January 5th, 2011, 03:29 AM
Registered User
 
Join Date: Jan 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert access data to xml

Hi thanks a lot for tour response.

I m beginner to xml so sure my code is quite wrong lol.

So i have to format values from database to xml file like this one :

Xml template:

Code:
<slideshow>
	<photo image="images/01.jpg" bigimage = "images/big/01.jpg" target="_blank" lightboxinfo="Description for image 1" url="http://www.flashxml.net"><![CDATA[Hello]]></photo>
	<photo image="images/02.jpg" bigimage = "images/big/02.jpg" target="_blank" lightboxinfo="Description for image 2" url="http://www.flashxml.net"><![CDATA[Download the new<br>Image Scroller]]></photo>
	</slideshow>
And values are coming from access database (see my first post)

So could you help me?

Thanks a lot.
Reply With Quote
  #4 (permalink)  
Old October 3rd, 2012, 10:39 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the post!
I'm relatively new to xml and this problem seemed rather impossible to solve by myself. But now I got what I did wrong.



________________________
mkv to mp4
Reply With Quote
Reply


Thread Tools
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
Access, how to convert data type from text to number cindyl Access 4 October 4th, 2010 12:58 PM
code of convert xml data type in string by C# prafullaborade XML 2 May 24th, 2008 08:49 AM
Select Data From Database and Convert to XML ozzy XML 1 February 13th, 2005 06:32 AM
Convert from xml to Access database lxu XSLT 0 June 3rd, 2004 02:24 PM
Error Data When Convert Excel to Access rpitoyo Pro VB Databases 0 August 5th, 2003 01:05 AM



All times are GMT -4. The time now is 03:13 PM.


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