根据xml文件中属性的更改更新Java类中的数据 [英] update data in java class as per change in attribute in the xml file

查看:62
本文介绍了根据xml文件中属性的更改更新Java类中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向xml定义文件添加一个属性

I want to add an attribute to the xml defination file

现在,我希望将此更改反映在java类中.你能建议如何做到吗?我也想将此属性添加为一个Java类中的数据成员,即getter和setters.我已经做到了.我想知道如何将xml节点中的值分配给此类中的java属性.请只告诉我逻辑.

Now i want this change to be reflected in a java class . Can you suggest as to how it can be done . Also i want to add this attribute as a data member in one java class with it;s getter and setters . That i have done . I want to know how to assign the value from the node of the xml into the java attribute in this class . Please tell me only logic .

推荐答案

由于您已经具有xml文件的架构,并且想要数据类型的Java类,请考虑使用

As you already have a schema for your xml files and you want java classes for the data types, consider using JAXB. This xml binding API can autogenerate classes from schemas and it provides convenient methods to marshal and unmarschal XML documents. (IAW: "convert an XML into java instances and vice versa).

这篇关于根据xml文件中属性的更改更新Java类中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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