Go Back   Dreamweaver Club Forums > Dreamweaver forums > Spry
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 09-25-2008, 12:31 AM   #1
Join Date: Sep 2008
Posts: 3
Default Spry XML Data Set, accessing specific rows

Hello. I've been trying to build a website using Spry XML Data Sets, and while I've accomplished my goals for now, I don't think the solution I came up with is the best.

The website consists of several areas that show projects. Each project has several fields that are to be filled with content retrieved from the xml files, but the projects are not all exactly alike and some have specific fields that others don't require.

All the info is available in several languages, so for now I've created an xml file for each one. Here's what an xml file could be like:
   <project name="proj1">
      <title>project one</title>
      <slogan>project one is great</slogan>
   <project name="proj2">
      <title>project two</title>
      <team>team alpha</team>
      <description>it was something we did</description>
This dataset, for simplicity purposes, is not dependent on the language:
var dsProjects = new Spry.Data.XMLDataSet("projects.xml", "project_list/project");
And then there are the content areas:
<div id="proj1">
   <p>title goes here</p>
   <div id="gallery">
   <p>date goes here</p>
   <div id="pub">
      <p>slogan goes here</p>
<div id="proj2">
   <p>title goes here / date goes here</p>
   <div id="team stuff">
      <p>team goes here</p>
         <p>description goes here</p>
So as you see, each project has its own structure. This makes using spry:repeat a not very effective method for filling in all the content. Ideally I should be able to access each row in the dataset through some sort of value, like id, or one of its children's values. The ds_RowID depends on the row order, so unless there's another way to use it, it doesn't solve my problem.

Here's what I've come up with:
<div id="proj1" spry:region="dsProjects" spry:repeat="dsProjects">
   <p spry:if="'{@id}'=='proj1'">{title}</p>
   (same method for each other element I need to retrieve from the xml dataset)
This works (in FF3 OSX, at least), although there are some other problems that might make it necessary to create a spry:region (or at least use spry:repeat) for each field. Anyway, it sounds silly and wasteful to go through every row of the dataset everytime for each of the fields that need to be filled.

My hope is that I'm ignorant of some much better method of achieving my goals, something more direct and elegant.

Can anyone help me out with this? Thank you very much in advance.
maguskrool is offline   Reply With Quote

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 On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:17 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com