Copy link to clipboard
Copied
Hello,
I am a CF Programmer who would normally use SQL as a datasource, however for a new project I thought I'd use XML where possible. I wanted to create an XML based navigation for the site but am having trouble figuring out the right way to structure the XML items and also parsing them back out.
The site is for travel type info, and as we grow counties, areas, projects, etc. will be added - So I saw the structure like so:
<data>
<county>County A</county>
<project>A Map</project>
<project>A Article</project>
<project>A Book</project>
</data>
This is of course wrong, and i have tried variations of the structure, but I know one of you gurus can point me in the right direction...
The gist is that each "County" can and will have many "Projects" associated with it. So I wanted to define some Counties and have their 'children' be the associated projects, so a nav would read like;
COUNTY A
A Map
A Article
A Book
COUNTY B
B Map
B Article
B Map
But no matter what I do, spry, cfml, etc I cannot query the XML for the PARENT (County) and then the CHILDREN that go only with that Parent.
without repeating the parent with each child.
Obviously this is not a big deal, for some reasons my skillset is broken today (including finding a tutorial that solves this!) So any point in the right direction will be greatly appreciated.
Thanks
Copy link to clipboard
Copied
Can't help with the ColdFusion side of things, but the XML structure might look like this:
<data>
<county>
<name>County A</name>
<project>A Map</project>
<project>A Book</project>
<project>A Article</project>
</county>
<county>
<name>County B</name>
<project>B Map</project>
<project>B Book</project>
<project>B Article</project>
</county>
</data>
Alternatively:
<data>
<county id="countyA">
<project>A Map</project>
<project>A Book</project>
<project>A Article</project>
</county>
<county id="countyB">
<project>B Map</project>
<project>B Book</project>
<project>B Article</project>
</county>
</data>
Copy link to clipboard
Copied
I did a project while back for a library of forms and documents. Each form or document had a category. I had to display the category then children listed under that category with links. The XML feed from the database in relation to yours was like
<data>
<project>
<projectname>A Map</projectname>
<county>County A</county>
<project>
<data>
In order to display the project name under their county, I used the Muenchian Method for sorting in the XSL file. This sorting method works great on small and large files. I use this method setting lightbox of with galleries, and sometimes for loading the spry menu for navigation.
Here is a link for the method:
http://www.jenitennison.com/xslt/grouping/muenchian.html
David Pearson
www.saludalabs.com
www.workhorsecreative.net