本文介绍了Android中JAXB的标准等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个使用XML请求和响应通过HTTP POST与服务器进行通信的APP.由于版权限制,我无法使用SIMPLE XML来(至少部分地)执行JAXB通常会执行的操作,并且从我拥有的所有信息来看,我无法在Android上使用JAXB.

I am building an APP that uses XML requests and responses to communicate with a server via HTTP POST. Due to copyright restriction I cannot use SIMPLE XML to do (at least partially) what JAXB would normally do, and from all the information I have JAXB cannot be used on Android.

我使用XmlSerializer来构建请求,并使用XMLPullParser来解析响应,但我不喜欢代码的样子,并且无法在Android SDK中找到与JAXB等效的标准.

I did the job using XmlSerializer to build the request and XMLPullParser for parsing the response but I don`t like how the code looks like and I was not able to find any standard equivalent for JAXB in the Android SDK.

是否可以使用任何SDK组件将XSD架构文件转换为Java类,然后使用marshaller/unmarshaller到XML文件或从XML文件使用marshaller/unmarshaller?或者我仍然坚持使用XmlSerializer/XMLPullParser?

Is there any SDK component that I can use to transform the XSD schema files to Java classes and then use marshaller/unmarshaller to/from a XML file or I am stuck with using XmlSerializer/XMLPullParser?

推荐答案

否.

欢迎您使用DOM或SAX代替XmlPullParser,就像在经典Java中一样.

You are welcome to use DOM or SAX instead of XmlPullParser, just as you can in classic Java.

除了SimpleXML之外,还有针对Android的多个XML解析库.

There are also several XML parsing libraries for Android, beyond just SimpleXML.

这篇关于Android中JAXB的标准等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 06:24