久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Android 中將 XML 文件解組為 Java 對象?

Unmarshalling XML files into Java objects in Android?(在 Android 中將 XML 文件解組為 Java 對象?)
本文介紹了在 Android 中將 XML 文件解組為 Java 對象?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用 Internet 上的 API,它將對象編組為 XML 文件.鑒于 XSD 文件也可用,我希望能夠在下載文件后將它們解組回 Java 對象.

I'm making use of an API on the internet that is marshalling objects to XML files. Given that the XSD files are also available I'd like to be able to unmarshall them back in to Java objects once I've downloaded the files.

環(huán)顧四周,看起來 JAXB 是在 Java 中執(zhí)行此操作的默認(rèn)庫,但正如我在開發(fā)移動應(yīng)用程序時(shí),額外的 8.6MB 依賴是不可接受的.我還找到了 XStream,但它的大小仍然為 7.9MB.

After looking around it looks like JAXB is the default library for doing this in Java, but as I'm developing a mobile app the extra 8.6MB dependency just isn't acceptable. I also found XStream, but it still weighs in at 7.9MB.

在 Android SDK 周圍一探究竟,似乎唯一可用的真正 XML 解析器是 SAX.

Poking around the Android SDK it looks like the only real XML parser available is SAX.

那么問題來了:

  1. 有沒有辦法讓 SAX 做我想做的事?
  2. 我錯(cuò)過了 Android SDK 中的另一個(gè)工具嗎?
  3. 是否有另一個(gè)庫(要小得多)可以做到這一點(diǎn)?

謝謝.

推薦答案

有很多工具可以在 Java 和 XML 之間轉(zhuǎn)換對象,但我熟悉的工具沒有一個(gè)比你找到的那些更小.但是,根據(jù)對象圖的復(fù)雜性,SAX 可能就是您所需要的,而且開銷很小.訣竅是在 SAX 事件處理程序中自己構(gòu)建對象圖.在 XML 編組器如此廣泛可用之前,我已經(jīng)在幾個(gè)項(xiàng)目中使用過這種技術(shù),雖然它需要更多的工作,但它很有效.

There are lots of tools to translate objects between Java and XML, but none of those I'm familiar with are any smaller than the ones you found. However, depending on the complexity of your object graph, SAX may be all you need and it has very little overhead. The trick is to build up the object graph yourself inside the SAX event handlers. I've used this technique in a couple of projects before XML marshalers were so widely available, and although it takes a little more work, it is effective.

這篇關(guān)于在 Android 中將 XML 文件解組為 Java 對象?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 日本久久精品视频 | 日本aⅴ中文字幕 | 亚洲国产一区二区三区四区 | 久久国产精品-国产精品 | 日本激情视频中文字幕 | 日韩久久久久久久久久久 | 久久久久一区 | 精品1区2区 | 国产第一页在线观看 | 色五月激情五月 | 国产成人aⅴ | 一区二区三区欧美大片 | 中文字幕视频一区 | 五月天国产 | 国产精品一区二区视频 | 国产99精品| 国产精品欧美一区二区三区不卡 | 福利视频1000| 奇色影视 | 欧美亚洲激情 | 91视频.com | 在线观看www视频 | 午夜影院网站 | 老司机免费视频 | 欧美中文字幕一区二区三区 | 午夜在线 | 拍真实国产伦偷精品 | 午夜精品一区二区三区在线播放 | 久久久久99| 日韩喷潮| 免费在线一区二区 | 日韩欧美一二三区 | 美女午夜影院 | 日韩在线视频免费观看 | 日韩一区二区在线播放 | 在线中文字幕av | 国产精品视频在线观看 | 天堂资源最新在线 | 日本精品网站 | 精品在线观看一区二区 | 欧美aⅴ|