<?xml version="1.0"?>
<EMPLOYMENT_OPPORTUNITIES>
<OPPORTUNITY id="0">
<INDEXABLE>0</INDEXABLE>
<POSITION>Job1</POSITION>
<DATELINE>03/17/2014</DATELINE>
<LOCATION>files/examplefile.pdf</LOCATION>
</OPPORTUNITY>
<OPPORTUNITY id="1">
<INDEXABLE>0</INDEXABLE>
<POSITION>Job2</POSITION>
<DATELINE>03/17/2014</DATELINE>
<LOCATION>files/examplefile.pdf</LOCATION>
</OPPORTUNITY>
<OPPORTUNITY id="3">
<INDEXABLE>1</INDEXABLE>
<POSITION>Job3</POSITION>
<DATELINE>03/18/2014</DATELINE>
<LOCATION>files/examplefile.pdf</LOCATION>
</OPPORTUNITY>
</EMPLOYMENT_OPPORTUNITIES>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Employee Opportunity Info</h2>
<table border="1">
<tr>
<td>Opportunity</td>
<td>INDEXABLE</td>
<td>POSITION</td>
<td>DATELINE</td>
<td>LOCATION</td>
</tr>
<xsl:for-each select="EMPLOYMENT_OPPORTUNITIES/OPPORTUNITY">
<tr>
<td><xsl:value-of select="@id"/></td>
<td><xsl:value-of select="INDEXABLE" /></td>
<td><xsl:value-of select="POSITION" /></td>
<td><xsl:value-of select="DATELINE" /></td>
<td><xsl:value-of select="LOCATION" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
This may give you some ideas on how to use simplexml to update an XML file.
Open in new window