Solved: Xml

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

dudeking

Thread Starter
Joined
Feb 7, 2007
Messages
483
Hey!!

I am creating a site which is basically a list of books populated from a xml file called books.xml. Books have a title, author, price and genre.

I can use either Javascript or XSLT and display these perfectly.

But I want to be able to order by different values and also display say only books of the genre children or educational.

If I display it with XSLT I can do this, but it means having a different XSLT style sheet for each 'view'. Is there no way to inject data into an XSLT sheet before I load it with ajax?

For example

Code:
<xsl:sort select="price"/>
Is there any way I could use javascript to alter that from price to author? Rather than having different style sheets with just one line different. I can't find a way to pass a value to the XSLT document.

Or forgetting all that if I just use parse the XML with javascript is there anyway or ordering it using that?
 
Joined
Jul 12, 2008
Messages
410
How about a server side script to generate the xslt on the fly based on some vale in the query string? (hint php)

It shouldnt be too hard to do if you set the right content headers.
 

dudeking

Thread Starter
Joined
Feb 7, 2007
Messages
483
I did try this, but it seems the xsl is not recognised if it has an extension of .PHP and PHP won't run if it has an extention of .xsl. In the end I just gave up on XSLT and just used simpleXML in PHP to parse it. Seemed alot easier tbh.
 
Joined
Jul 12, 2008
Messages
410
Ah right, I tohught setting the content type headers would get it recognized. Obviously not.
Good then :)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top