[thelist] Using php to transform xml

Chris Price chris.price at choctaw.co.uk
Thu May 24 16:17:39 CDT 2012


Hi there

I know I should probably do a proper course on xml and xslt but I just need
a really quick solution for this small job - then I can probe further.

I have an xml file with nested tasks:

<plan>
<task>
  <title>Walk</title>
  <status>prop</status>
  <description>Learn to walk</description>
  <notes>Gaining strength and balance</notes>
</task>

I want to output xhtml so that each task has a container with a class
equivalent to its 'status', eg. <div
class='prop'><title/><description/><notes/></div>

This is a snippet of my xsl file:

<h1>Planner</h1>
<xsl:for-each select="plan/task">
<div>
<span><xsl:value-of select="status" /></span>
<span class='title'><xsl:value-of select="title" /></span>
<span class='description'><xsl:value-of select="description" /></span>
<span class='notes'><xsl:value-of select="notes" /></span>
</div>
</xsl:for-each>

I don't want a 'status' span, I want it to be the class of the div.

Does this make sense and is there a relatively simple solution?

Thanks

Chris.Price
@Choctaw.co.uk <http:\\choctaw.co.uk>
0777 629 0227

Design is my native language

Choctaw Media Ltd is a company registered in England and Wales (04627649)


More information about the thelist mailing list