1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Xml

Discussion in 'Web Design & Development' started by dudeking, Jan 5, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. dudeking

    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?
     
  2. Nick Tompson

    Nick Tompson

    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.
     
  3. dudeking

    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.
     
  4. Nick Tompson

    Nick Tompson

    Joined:
    Jul 12, 2008
    Messages:
    410
    Ah right, I tohught setting the content type headers would get it recognized. Obviously not.
    Good then :)
     
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/972888

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice