XML question

Discussion in 'XML' started by Aart Nicolai, Nov 30, 2003.

  1. Aart Nicolai

    Aart Nicolai Guest

    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
     
    Aart Nicolai, Nov 30, 2003
    #1
    1. Advertising

  2. In article <Xns9443E0C9AA2A7aartnicolaihotmailco@195.121.6.68>,
    Aart Nicolai <> wrote:

    [...]

    % 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.
    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Nov 30, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bomb Diggy
    Replies:
    0
    Views:
    447
    Bomb Diggy
    Jul 28, 2004
  2. Tony Prichard
    Replies:
    0
    Views:
    734
    Tony Prichard
    Dec 12, 2003
  3. Mark Van Orman

    embedding xml in xml as non-xml :)

    Mark Van Orman, Sep 14, 2004, in forum: XML
    Replies:
    5
    Views:
    481
    Patrick TJ McPhee
    Sep 15, 2004
  4. Andy
    Replies:
    0
    Views:
    539
  5. Erik Wasser
    Replies:
    5
    Views:
    463
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page