|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
XML/XSL -> HTML problem
Having some small issues. I get an XML file as an on-line feed, and I would like to transform it. Here's an example of what it looks like:
<?xml version="1.0" encoding="ISO-8859-1"?> <feed ver="2.0"> <head> <name>My Name</name> <ident>5485858</name> </head> <cc> <locale>Home</locale> <date>5/24/04</date> </cc> </feed> This is just an example now ![]() Anyway, I only need the "//feed/head/name" and "//feed/cc/locale" portions of this document, everything else can go to the wayside. Here's what my XSL looks like: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl utput method="html" indent="yes" /><xsl:template match="feed"> <html><head><title>Current Feed</title></head> <body><table border='1'><xsl:apply-templates/></table></body></html> </xsl:template> <xsl:template match="head/name"> <tr><td><xsl:apply-templates/></td></tr> </xsl:template> <xsl:template match="cc/locale"> <tr><td><xsl:apply-templates/></td></tr> </xsl:template> </xsl:stylesheet> This does work, but the remainder of the XMl doc is just thrown into the top of the HTML page as garbage. Is there anyway for it to just not display this? Thanks |
|
#2
|
||||
|
||||
|
Just throw in the following template:
Code:
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
Let me know if that works, I didn't test anything. |
|
#3
|
|||
|
|||
|
Thank you for the quick response Matt, unfortunatly it seems to not have made a difference. I'm now also running into the problem of how to do columns in this thing, instead of each element in it's own row, put them in one row with two columns. XSL is not as easy as it's made out to be. Here is what my XSL file looks like now:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl utput method="html" indent="yes" /><xsl:template match="/"> <html><head><title>Current Feed</title></head> <body><table border='1'><xsl:apply-templates/></table></body></html> </xsl:template> <xsl:template match="head/name"> <tr><td><xsl:apply-templates/></td></tr> </xsl:template> <xsl:template match="cc/locale"> <tr><td><xsl:apply-templates/></td></tr> </xsl:template> </xsl:stylesheet> Thank you again, tibmeister |
|
#4
|
||||
|
||||
|
This works (tested):
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <html><head><title>Current Feed</title></head> <body><table border="1"> <xsl:apply-templates select="feed/head/name"/> <xsl:apply-templates select="feed/cc/locale"/> </table></body></html> </xsl:template> <xsl:template match="name"> <tr><td><xsl:value-of select="."/></td></tr> </xsl:template> <xsl:template match="locale"> <tr><td><xsl:value-of select="."/></td></tr> </xsl:template> </xsl:stylesheet> |
|
#5
|
|||
|
|||
|
It was the select part that I couldn't find! Thank you soo much! no onto the next problem (the socond one I mentioned)
Thank you, tibmeister |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML/XSL -> HTML problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|