XML文件的生成與解析html
有兩種方式,JAXB和XStreamjava
經過參考如下博客和源代碼能夠掌握此內容;spa
ParseXMLBYJAXB類 使用Jaxb實現XML文件的生成與解析.net
ParseXMLBYXStream類 使用XStream API解析XML文件插件
ParseXMLBYDOM類 DOM實現XML文件的生成與解析xml
JAXB須要注意的地方htm
@XmlElement、@XmlAttribute註解能夠在屬性或getter/setter方法上面配置,注意因爲 @XmlAccessorType的默認值是 XmlAccessType.PUBLIC_MEMBER:java對象中全部的public訪問權限的成員變量和經過getter/setter方式訪問的成員變量;對象
因此要麼屬性的修飾符是private,要麼不寫該屬性的getter/setter,不然會拋出以下異常:blog
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:get
1 counts of IllegalAnnotationExceptions類的兩個屬性具備相同名稱 "id"
參考博客
XML文件的做用與結構
http://blog.csdn.net/axi295309066/article/details/52760959
操做XML文件的四種底層方式
http://www.cnblogs.com/ygj0930/p/6651643.html
DOM方法生成XML
https://zhidao.baidu.com/question/159160111.html
使用XStream插件把JavaBean轉換爲xml
http://blog.csdn.net/liboyang71/article/details/73250386
http://www.javashuo.com/article/p-rfavivsm-bo.html
JAXB和XStream相比較
http://www.javashuo.com/article/p-qzjhpduo-bb.html
Spring MVC返回XML格式的數據
http://blog.csdn.net/haige_lin/article/details/65435884
JAXB註解
http://blog.csdn.net/nxdxmg/article/details/46926521
JAXB示例