0

I have a html file like this:

<html lang="en,us">
    <head>
        <title>Welcome to the Oracle</title>
    </head>
    <body>
        <table width="100%" cellspacing="5" cellpadding="5" border="0">
            <tr>
                <td>
                    <h2>Welcome to the Oracle</h2>
                    <p>The following processes</p>
                    <ol>
                        <li>Process1</li>
                        <li>Process2</li>
                        <li>Process3</li>
                    </ol>
                </td>
            </tr>
        </table>
    </body>
</html>

If I apply this xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:for-each select="/html/body/table/tr/td/ol/li">
                <xsl:value-of select="li"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

I am only getting nothing.

If I try this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:for-each select="/html/body/table/tr/td/ol/li">
                <xsl:value-of select="/html/body/table/tr/td/ol/li"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Then getting this:

Process1 Process1 Process1

How do I get this?

Process1 Process2 Process3

1 Answer 1

2

Instead of

    <xsl:for-each select="/html/body/table/tr/td/ol/li">
            <xsl:value-of select="li"/>
    </xsl:for-each>

you want

    <xsl:for-each select="/html/body/table/tr/td/ol/li">
            <xsl:value-of select="."/>
    </xsl:for-each>

as inside the for-each the context is the li element.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Martin. Thats what I was looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.