如何使用 lex(flex) yacc(bison) 将 XML 表转换为 HTML 表

问题描述

**from this type of xml code (program will take this type of xml code as input)**

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="bookstore.xsl"?>
    <bookstore>
      <book category="cooking">
        <title lang="en">Everyday Italian</title>
        <author>Giada De Laurentiis</author>
        <year>2005</year>
        <price>30.00</price>
      </book>
      <book category="web" cover="paperback">
        <title lang="en">Learning XML</title>
        <author>Erik T. Ray</author>
        <year>2003</year>
        <price>39.95</price>
      </book>
    </bookstore>

我希望我的程序为上面相应的 XML 文件返回这个 html 文件

    <html>
    <body>
        <table>
            <tbody>
                <tr>
                    <th>Bookstore</th>
                    <th>Book</th>
                    <th>title</th>
                    <th>author</th>
                    <th>year</th>
                    <th>price</th>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td>Everyday Italian</td>
                    <td>Giada De Laurentiis</td>
                    <td>2005</td>
                    <td>30.00</td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td>Learning XML</td>
                    <td>Erik T. Ray</td>
                    <td>2003</td>
                    <td>39.95</td>
                </tr>
            </tbody>
        </table>
    </body>
    </html>

不需要考虑所有其他类型的 xml 文件,如果文件不包含表,它将从 yyparse 调用 yyerror。代码中可以有多个表,一个表可以包含另一个表。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)