在GWT服务器端解析XML文件 [英] Parse XML file in GWT server-side

查看:99
本文介绍了在GWT服务器端解析XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在服务器端解析GWT中的XML文件?我无法使用XMLParser,因为它仅适用于客户端。我需要读取服务器端的XML文件,将内容转换为List,并使用GWT-RPC将它们返回给客户端。



预先感谢。

解决方案

我使用Apache Project中的JAXB。
http://jaxb.java.net/



它与GWT XML库有点不同。您可以使用xsd定义文件定义,运行程序来创建一堆数据传输类,然后一次解析xml文件,而不是编写代码来通过xml树进行爬取并进行自己的处理。



一些注意事项:确保JAXB jar位于构建路径中的jre库之上。
最新版本和GAE存在问题,所以如果您使用20090708版本的GAE棒。


How do I parse an XML file in GWT on the server side? I can't use XMLParser because that works only on the client. I need to read an XML file on the server side, convert the contents into a List and return them to the client using GWT-RPC.

Thanks in advance.

解决方案

I use JAXB from the Apache Project. http://jaxb.java.net/

It is a little different from the GWT XML library. Instead of writing code to crawl through the xml tree and do your own processing, you define the file definition using xsd, run a program to create a bunch of data transfer classes and then parse the xml file(s) all at once.

A few caveats:

Make sure the JAXB jars are above the jre libraries in your build path. There are issues with the latest versions and GAE, so if you are using GAE stick with the 20090708 version.

这篇关于在GWT服务器端解析XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆