如何从XML生成JAXB类 [英] How to generate JAXB classes from just XML

查看:137
本文介绍了如何从XML生成JAXB类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从xml生成不提供架构的类。我知道这几乎没用,但事实是我们有xml,它是结构化的,我们应该能够从xml创建一个模型。在过去,我已经手工完成了,但是我正在使用的当前xml文档非常大,而且我的时间可能会更好地用于构建满足我需要的东西。但是,我猜它已经完成了,我找不到它。

I need to generate classes from xml that doesn't provide a schema. I understand this is near useless, but the fact is we have xml, it's structured, and we should be able to create a model from the xml. In the past I've done it by hand, but the current xml documents I am working with are quite large and my time would probably be better spent building something that does what I need. But, I am guessing it has already been done, and I just can't find it.

任何指针?

推荐答案

有许多可用的工具(快速谷歌搜索应该可以提取一些),可以从XML生成XSD,假设几乎所有的字符串类型。您应该能够使用该XSD运行JAXB来获取类。

There are many tools available (a quick google search should fetch you some) that can generate XSD from XML assuming string type for almost everything. You should be able to use that XSD to run JAXB to get classes.

这是一个在线工具,可让您这样做。

Here's an online tool that lets you do that.

这是一个屏幕上限:

And here is a screen cap:

这篇关于如何从XML生成JAXB类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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