本来想写一篇在Android下使用XStream解析XML文件的文章,后来发现http://yunzhongxia.javaeye.com/blog/539827 已经写的很好了,所以就不写了。把地址记录下来。

使用XStream时注意到官方文档的一句话:

 

XStream fails to unmarshal my given XML and I do not know why?

By default XStream is written for persistence i.e. it will read the XML it can write. If you have to transform a given XML into an object graph, you should go the other way round. Use XStream to transfer your objects into XML. If the written XML matches your schema, XStream is also able to read it. This way is much easier, since you can spot the differences in the XML much more easy than to interpret the exceptions XStream will throw if it cannot match the XML into your objects.