View Full Version : Displaying different XML information through a URL variable, via PHP

12-02-2003, 11:18 PM
If this is in the wrong forum, my apologies, i felt it would work best in PHP.

Ok, the final goal for my site is to be able to control what content from an XML file is shown on a page via PHP. Ive got the XML file and its coresponding XSLT file, with some aspects of it that i want to have as variables. example:

<year id="2001">
<show id="20010509">
<date id="05/09/01">
<artist>Tim Solo (A)</artist>
<venue>The Stanhope House</venue>
<year id="2003">
<show id="20030227" status="canceled">
<date id="02/27/03">
<artist>Tim Solo (A)</artist>
<venue>32 Bleu</venue>
<city>Colorado Springs</city>

part of one particular xslt file:

<xsl:template match="tour">
<xsl:for-each select="year[@id='2003']/show">
<xsl:value-of select="date/@id"/>
<xsl:value-of select="artist"/>
<xsl:value-of select="location/venue"/>: <xsl:value-of select="location/city"/>, <xsl:value-of select="location/state"/>

i want to be able to set id='2003' as a variable to be determined by the URL, like /tour.php?id=2003.

Now, I have very little knowledge of PHP. I dont like asking for answers to things i havent fiddled with completely, but I dont know where to start when it comes to even parsing the XML. Any help would be appriciated.

12-02-2003, 11:40 PM
I have no idea about xml, and don't know if you can mix php with it. If you can, then you can use:

select="year[@id='<?php echo $_GET['id']; ?>']/show">

Which will return whatever the id is on here tour.php?id=2003

12-03-2003, 06:14 PM
Hmm, istead of xslt, you may want to use the xml parser functions. You should be able to find them on php.net