This is my first try at xml/xsl. I have an xml file with hundreds of job offers from another portal that I'd like to put on my site.
I need two things. First, list all data in rows (employer, post, province). Second, link posts and let visitors read full description of a particular job offer.
So far, I've done the following:
#sample of xml source file
<?xml version="1.0" encoding="iso-8859-2"?>
<ADVERTISEMENTS creation_date="2005-06-27">
<ADVERTISEMENT start_date="2005-06-27" end_date="2005-07-02" update_date="2005-06-27" id="91728"><EMPLOYER>Personality Doradztwo Personalne</EMPLOYER>
<POST>HR Manager / Specjalista ds. HR </POST>
<WORKPLACE>
<PROVINCE>mazowieckie</PROVINCE>
</WORKPLACE>
</ADVERTISEMENT></ADVERTISEMENTS>
#my xsl file
#It displays data as required, but I have trouble with retrieving "id" variable from xml file and putting it into hyperlink
<?xml version="1.0" encoding="iso-8859-2"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="<xsl:template match="/">
<html>
<body>
<h2>Job offers</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Employer</th>
<th align="left">Post</th>
<th align="left">Province</th>
</tr>
<xsl:for-each select="ADVERTISEMENTS/ADVERTISEMENT">
<tr>
<td><xsl:value-of select="EMPLOYER"/></td>
<td>
<a href="maintwo.php?id={id}">
<xsl:value-of select="POST"/></a></td>
<td><xsl:value-of select="WORKPLACE/PROVINCE"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
#xml and xsl file are loaded into main.php file to suit my web site, like this:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<title>Job offers</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("jobs.xml")// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("template1.xsl")// Transform
document.write(xml.transformNode(xsl))</script>
</body>
</html>
# I only wonder why IE is the only browser that displays the results. Firefox, NN and Opera don't.
#Finally, I need to find out a way to display detailed description of particular job offer. And I have no idea how to do this, whether I should do this in a different file (as you can see, I'm trying to link to maintwo.php) or maybe I could just use different template and stick to the same php file.
Hoping someone can give me good tips how to cope with these problems.
Wiktor
I need two things. First, list all data in rows (employer, post, province). Second, link posts and let visitors read full description of a particular job offer.
So far, I've done the following:
#sample of xml source file
<?xml version="1.0" encoding="iso-8859-2"?>
<ADVERTISEMENTS creation_date="2005-06-27">
<ADVERTISEMENT start_date="2005-06-27" end_date="2005-07-02" update_date="2005-06-27" id="91728"><EMPLOYER>Personality Doradztwo Personalne</EMPLOYER>
<POST>HR Manager / Specjalista ds. HR </POST>
<WORKPLACE>
<PROVINCE>mazowieckie</PROVINCE>
</WORKPLACE>
</ADVERTISEMENT></ADVERTISEMENTS>
#my xsl file
#It displays data as required, but I have trouble with retrieving "id" variable from xml file and putting it into hyperlink
<?xml version="1.0" encoding="iso-8859-2"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="<xsl:template match="/">
<html>
<body>
<h2>Job offers</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Employer</th>
<th align="left">Post</th>
<th align="left">Province</th>
</tr>
<xsl:for-each select="ADVERTISEMENTS/ADVERTISEMENT">
<tr>
<td><xsl:value-of select="EMPLOYER"/></td>
<td>
<a href="maintwo.php?id={id}">
<xsl:value-of select="POST"/></a></td>
<td><xsl:value-of select="WORKPLACE/PROVINCE"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
#xml and xsl file are loaded into main.php file to suit my web site, like this:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<title>Job offers</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("jobs.xml")// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("template1.xsl")// Transform
document.write(xml.transformNode(xsl))</script>
</body>
</html>
# I only wonder why IE is the only browser that displays the results. Firefox, NN and Opera don't.
#Finally, I need to find out a way to display detailed description of particular job offer. And I have no idea how to do this, whether I should do this in a different file (as you can see, I'm trying to link to maintwo.php) or maybe I could just use different template and stick to the same php file.
Hoping someone can give me good tips how to cope with these problems.
Wiktor