문제

I have an xml stored in database table. i need to get the xml and modify few elements and put the xml back in the database.

I am thinking to use JDOM or JAXB to modify the xml elements. Could you please suggest which one is better regarding the performance?

Thanks!

도움이 되었습니까?

해결책

JAXB and JDOM and completely different things. JAXB will serialize java objects into an XML format and vice versa. JDOM simply reads in the XML file and stores it in a DOM tree which can then be used to modify the xml itself. So better if you go for JDOM.

다른 팁

JAXB is to be used when you have objects where the attribute values are stored in XML hence you can parse an xml document and it gives you a java objects and then you can write these back.

Quite a bit of work if you want to simple change some values. And it doesn't work with arbitrary xml files, JAXB has it's own format linked to your object's definitions.

JDOM creates also objects but the objects used are XML objects like Element, NodeList, ...

If you just want to change some values -> why not reading the xml file as a plain text file and use string operations to make your changes.

Or of the modification is more logicaly defined -> use an XSLT and a stylesheet translator.

Googling for XSLT and Java will give you tons of examples.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top