Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 April 20th, 2011, 09:21 AM
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loop through recordset to output XML

Hi everyone,

I need to generate an XML file from the 2 tables below:

dbo.Guides - ID (int), Title (varchar)

dbo.Steps - ID (int), GuideID (int), Info (varchar)

Each guide has many steps which are linked by dbo.Guides.ID and dbo.Steps.GuideID

Here is my current attempt (recordsets are [1] SELECT * FROM dbo.guides [2] SELECT * FROM dbo.steps):

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<internal_guides>
<% While (Not guides.EOF) %>
	<guide>
		<id><![CDATA[<%=(guides.Fields.Item("ID").Value)%>]]></id>
		<title><![CDATA[<%=(guides.Fields.Item("Title").Value)%>]]></title>
<% Do While (steps.Fields.Item("GuideID").Value) = (guides.Fields.Item("ID").Value) %>
		<step><![CDATA[<%=(steps.Fields.Item("Info").Value)%>]]></step>
<% steps.MoveNext()
	Loop %>
	</guide>
<% guides.MoveNext()
	Wend %>
</internal_guides>
<%
guides.Close()
	Set guides= Nothing
steps.Close()
	Set steps = Nothing
%>
It outputs the XML OK if I remove the Do While... Loop and <steps> node, but when the Do While... Loop and <steps> node are present I get 'XML Parsing Error: not well-formed'.

I'm by no means an expert ASP guru, I'm hoping one of you experts can help on this as it is pretty urgent.

Thanks for any help you can give, it is much appreciated!! :)
Reply With Quote
  #2 (permalink)  
Old April 22nd, 2011, 04:43 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I think you should add one more tag for Steps. Example:

Code:
<% While (Not guides.EOF) %>
	<guide>
		<id><![CDATA[<%=(guides.Fields.Item("ID").Value)%>]]></id>
		<title><![CDATA[<%=(guides.Fields.Item("Title").Value)%>]]></title>
<steps>
<% Do While (steps.Fields.Item("GuideID").Value) = (guides.Fields.Item("ID").Value) %>
		<step><![CDATA[<%=(steps.Fields.Item("Info").Value)%>]]></step>
<% steps.MoveNext()
</steps>
 Loop %>
	</guide>
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
Reply With Quote
  #3 (permalink)  
Old April 25th, 2011, 11:04 AM
Authorized User
 
Join Date: Dec 2004
Location: Madurai, Tamil Nadu, India.
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

As well check for the special characters in the title that breaks the formation of the XML string.
__________________
Thanks in advance.

Regards,

Senthil Kumar M.
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
Output loop data to a string iloveoatmeal Classic ASP Basics 2 December 22nd, 2005 08:28 PM
recordset not showing up on page loop pablohoney Classic ASP Databases 1 December 14th, 2005 06:43 PM
Querying Recordset with a Loop rabu Access VBA 10 December 14th, 2005 04:49 PM
Filter recordset in loop Freddyfred Access 1 February 15th, 2005 09:09 AM



All times are GMT -4. The time now is 06:00 AM.


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