Click to See Complete Forum and Search --> : XML node data to HTML


draig_hand
04-29-2009, 04:41 PM
I've viewed forum threads and cannot find relevant answer so - here goes from a newbie:

I have a large XML file containing Questions & Answers - part shown here:
- <QZ>
- <PL>
- <PLEA>
- <PLEA107 answer="">
<category>1</category>
<question>PLEA107</question>
<answer />
<answer />
<answer />
<answer />
</PLEA107>
- <PLEA108 answer="">
<category>1</category>
<question>PLEA108</question>
<answer />
<answer />
<answer />
<answer />
</PLEA108>
</PLEA>
- <PLNE>
- <PLNE107 answer="">
<category>1</category>
<question>PLNE107</question>
<answer />
<answer />
<answer />
<answer />
</PLNE107>
</PLNE>
- <PLOK> note the full xml file contains 5000+ lines

I need to show a Question and Answer table or form as part of my web page (between <td> </td>). The table/form needs to show one question along with the four possible answers.

Assuming I use PLEA107 to identify the node I want, how do I get Node PLEA107, and children, to present themselves in a formatted table on my page.

I am hoping that this can be done using just HTML, Javascipt, XML or PHP.

Hope you can help in some way.

jkmyoung
04-30-2009, 11:10 AM
Seems really like an xsl thing. http://www.w3schools.com/xsl/default.asp


<xsl:template match="/*">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="PLEA107">
<tr>
<td><xsl:value-of select="question"/></td>
<xsl:apply-templates select="answer"/>
</tr>
</xsl:template>
<xsl:template match="answer">
<td><xsl:value-of select="."/></td>
</xsl:template>

draig_hand
04-30-2009, 12:42 PM
Thanks for your advice. I'll look into W3Schools and let you know how I get on.:)