XML question

A

Aart Nicolai

Hi,

I've a little, maybe stupid question, about XML/XSL.
I grab HTML from another website. I put this HTML code within my XML
file, because it's also well formed it;s not a problem. But I don't know
how I'm able to walk through those tags using XSL.

This is the specific part of the XML:
<WEER>
<TR>
<TD width="25%">Schiphol</TD>
<TD>zwaar bewolkt</TD>
<TD>7.4</TD>
<TD>96</TD>
<TD>OZO</TD>
<TD>4</TD>
<TD>3300</TD>
<TD>1004</TD>
</TR>
</WEER>

I'm now using this peace of XSL, but it's not working very well. I simply
just want to retrieve the contents of the "TD" tag.

<xsl:for-each select="/ROOT/PARENT/OBJECT/WEER/TR/TD">
<xsl:if test="position() = 1"><xsl:value-of
select="/ROOT/PARENT/OBJECT/WEER/TR/TD" /><br /></xsl:if>
</xsl:for-each>

Any suggestions ?

Thanks in advance,

Aart Nicolai
 
P

Patrick TJ McPhee

[...]

% I'm now using this peace of XSL, but it's not working very well. I simply
% just want to retrieve the contents of the "TD" tag.
%
% <xsl:for-each select="/ROOT/PARENT/OBJECT/WEER/TR/TD">
% <xsl:if test="position() = 1"><xsl:value-of
% select="/ROOT/PARENT/OBJECT/WEER/TR/TD" /><br /></xsl:if>
% </xsl:for-each>

What I get from this is the contents of the first TD tag. You could
get the same thing by making the xsl:value-of `select' attribute
be `.', and you could get the same thing possibly more efficiently
by moving the test for position up to the xsl:for-each, like so

<xsl:for-each select="/ROOT/PARENT/OBJECT/WEER/TR/TD[1]">
<xsl:value-of select="." /><br />
</xsl:for-each>

I suppose this isn't what you want, but I can only guess what you'd
like to do that's different. Do you want the contents of all the TD
elements? Then remove the restriction to the first element

<xsl:for-each select="/ROOT/PARENT/OBJECT/WEER/TR/TD">
<xsl:value-of select="." /><br />
</xsl:for-each>

Do you want them all before the <br/>? Then move the <br/> out of the
loop.

Hopefully something there will be helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top