简体   繁体   English

从 xml 文件创建 html 页面

[英]creating html page from xml file

I reading xml document which consists of html elements.我阅读了包含 html 元素的 xml 文档。 Now I need to fetch the data from that xml file and construct a HTML and display it using servlets or javascript.现在我需要从该 xml 文件中获取数据并构造一个 HTML 并使用 servlets 或 ZDE9B9ED78D2EEEE2E178 显示它。 How do I do that, please suggest any method or tutorials.我该怎么做,请提出任何方法或教程。

You should use XSLT for this task .您应该使用XSLT完成此任务 Start with a basic tutorial .基本教程开始。

You could use XSLT to transform your XML document into an XHTML page.您可以使用XSLT将 XML 文档转换为XHTML页面。

There's an open-source XSLT servlet available here .这里有一个开源的 XSLT servlet 可用。

Basically, in java there are 3 apis to read and parse xml data: * dom: reads whole file at once and lets you access data with random access.基本上,在 java 中,有 3 个 api 用于读取和解析 xml 数据: * dom:一次读取整个文件并允许您通过随机访问访问数据。 high memory usage.高 memory 使用率。 * sax: stream-reads file and lets you react on events. * sax:流式读取文件并让您对事件做出反应。 Low memory usage, more complicated than dom. memory 使用率低,比 dom 复杂。 * stax: similar to sax, but more modern interface, event based. * stax:类似于 sax,但更现代的界面,基于事件。 also low memory usage. memory 的使用率也很低。

How to present the information from the HTML file cannot be explained in a single answer here, hundreds of books were written about that.如何呈现 HTML 文件中的信息无法在这里用一个答案来解释,关于这个问题已经写了数百本书。 Among the possibilities are: You can do HTML creation yourself (prgramatically in java) or you could use JSP, JSF, Ruby on Rails, XSLT, Velocity, GWT, Tapestry, Wicket, JBoss Seam, WebWork, just to name a few. Among the possibilities are: You can do HTML creation yourself (prgramatically in java) or you could use JSP, JSF, Ruby on Rails, XSLT, Velocity, GWT, Tapestry, Wicket, JBoss Seam, WebWork, just to name a few.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM