在xsp页面中将xml显示到表中

时间:2021-07-18 22:16:07

im having this xml:

我有这个xml:

<Results><Row><COLLATION_NAME>latin2_bin</COLLATION_NAME><CHARACTER_SET_NAME>latin2</CHARACTER_SET_NAME><ID>77</ID><IS_DEFAULT/><IS_COMPILED>Yes</IS_COMPILED><SORTLEN>1</SORTLEN></Row><Row><COLLATION_NAME>utf32_esperanto_ci</COLLATION_NAME><CHARACTER_SET_NAME>utf32</CHARACTER_SET_NAME><ID>177</ID><IS_DEFAULT/><IS_COMPILED>Yes</IS_COMPILED><SORTLEN>8</SORTLEN></Row></Results>

for any query the number of rows is different, how can i display it into a table in a jsp page?

对于任何查询,行数不同,如何将其显示在jsp页面的表中?

1 个解决方案

#1


0  

You can do it with xslt, is like a style sheet for xml

你可以用xslt来做,就像xml的样式表

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Results">
<html>
    <body>
        <table>
            <xsl:for-each select="Row">
                <tr>
                    <td>
                        <xsl:value-of select="COLLATION_NAME"/>
                    </td>
                    <td>
                        <xsl:value-of select="CHARACTER_SET_NAME"/>
                    </td>
                    <td>
                        <xsl:value-of select="ID"/>
                    </td>
                    <td>
                        <xsl:value-of select="IS_DEFAULT"/>
                    </td>
                    <td>
                        <xsl:value-of select="IS_COMPILED"/>
                    </td>
                    <td>
                        <xsl:value-of select="SORTLEN"/>
                    </td>
                </tr>
            </xsl:for-each>
        </table>
    </body>
</html>
</xsl:template>
</xsl:stylesheet> 

More information in http://www.w3schools.com/xsl/ :)

有关更多信息,请访问http://www.w3schools.com/xsl/ :)

#1


0  

You can do it with xslt, is like a style sheet for xml

你可以用xslt来做,就像xml的样式表

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Results">
<html>
    <body>
        <table>
            <xsl:for-each select="Row">
                <tr>
                    <td>
                        <xsl:value-of select="COLLATION_NAME"/>
                    </td>
                    <td>
                        <xsl:value-of select="CHARACTER_SET_NAME"/>
                    </td>
                    <td>
                        <xsl:value-of select="ID"/>
                    </td>
                    <td>
                        <xsl:value-of select="IS_DEFAULT"/>
                    </td>
                    <td>
                        <xsl:value-of select="IS_COMPILED"/>
                    </td>
                    <td>
                        <xsl:value-of select="SORTLEN"/>
                    </td>
                </tr>
            </xsl:for-each>
        </table>
    </body>
</html>
</xsl:template>
</xsl:stylesheet> 

More information in http://www.w3schools.com/xsl/ :)

有关更多信息,请访问http://www.w3schools.com/xsl/ :)