Java¶ÔÏóXMLÐòÁл¯¿ò¼Ü£Simple2.0
Java¶ÔÏóXMLÐòÁл¯¿ò¼Ü£Simple2.0
SimpleÊÇÒ»¸öXMLÐòÁл¯¿ò¼Ü£¬Ò»¸öJava
°æ±¾¿íÈݵÄÐòÁл¯¿ò¼Ü£¬Äܹ»¿ìËÙÔÚJava
ƽ̨ÉÏ¿ª·¢XML¡£Ö§³Öͨ¹ýannotationsÍêÈ«ÅäÖû¯µÄXML½á¹¹£»Ìṩ°æ±¾¹ÜÀí¿ò¼ÜÔÊÐíÏòÇ°ºÍÏòºó¼æÈÝÐòÁл¯£»¸üºÃµÄÐÔÄÜ£¬Ê¹ÓÃÇáÁ¿¼¶StAXÌáÉýXML·´ÐòÁл¯
½ø³Ì£¬±ÈXStreamºÍJAXB¸ü¿ì£»Í¨¹ýnamespace annotationsÌṩÍêÈ«µÄÃüÃû¿Õ¼äÖ§³Ö£»°üÀ¨XMLÄ£°åϵͳ
Ä¿Ç°×îа汾Ϊ 2.0.1. ¹ÙÍøµØÖ·:http://simple.sourceforge.net/home.php
×¢£º²»¹ý±ÊÕßÈÏΪ£¬Èç¹ûÄãʹÓÃJavaSE 6.0£¬Ôò½¨ÒéʹÓÃÆä×Ô´øµÄJAXB
(Java Architecture for XML Binding).ÆäʹÓ÷dz£¼òµ¥£¬Ö§³Öͨ¹ýannotationsÍêÈ«ÅäÖû¯µÄXML½á¹¹¡£¶øÇÒÆäÒ²ÊÇJavaÖеÄÒ»¸ö¹æ·¶ÊµÏÖ£¬ JAX-RS¹æ·¶
¾ÍʹÓÃJAXBÀ´ÊµÏÖ¶ÔÏóµÄÐòÁл¯¹¦ÄÜ¡£
ÏÂÃæÊÇÒ»¸ö¼òµ¥Ê¾Àý:
Ïȶ¨ÒåÒ»¸öExample¶ÔÏó£¬ ÎÒÃÇÖ»ÐèÒª¼òµ¥µÄ¼ÓÉÏAnnoationºó£¬¾Í¿ÉÒÔ½øÐжÔÏóÓëXMLÖ®¼äµÄת»»¡£
@Root
public
class
Example {
@Element
private
String text;
@Attribute
private
int
index;
public
Example() {
super
();
}
public
Example(String text,
int
index) {
this
.text
=
text;
this
.index
=
index;
}
public
String getMessage() {
return
text;
}
public
int
getId() {
return
index;
}
}
½øÐÐXMLÐòÁл¯²Ù×÷:
Serializer serializer
=
new
Persister();
Example example
=
new
Example(
"
Example message
"
,
123
);
File result
=
new
File(
"
example.xml
"
);
serializer.write(example,&
Ïà¹ØÎĵµ£º
XMLÏÖÔÚÒѾ³ÉΪһÖÖͨÓõÄÊý¾Ý½»»»¸ñʽ,ËüµÄƽ̨ÎÞ¹ØÐÔ,ÓïÑÔÎÞ¹ØÐÔ,ϵͳÎÞ¹ØÐÔ,¸øÊý¾Ý¼¯³ÉÓë½»»¥´øÀ´Á˼«´óµÄ·½±ã¡£¶ÔÓÚXML±¾ÉíµÄÓ﷨֪ʶÓë¼¼Êõϸ½Ú,ÐèÒªÔĶÁÏà¹ØµÄ¼¼ÊõÎÄÏ×,ÕâÀïÃæ°üÀ¨µÄÄÚÈÝÓÐDOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Exten ......
<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:ËÎÌå;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@SimSun&qu ......
JAVAµÄ¿çƽ̨µÄÌØÐÔÉîÊÜjava³ÌÐòÔ±ÃǵÄϲ°®,µ«ÕýÊÇÓÉÓÚËüΪÁËʵÏÖ¿çƽ̨µÄÄ¿µÄ,ʹµÃËüºÍ±¾µØ»úÆ÷µÄ¸÷ÖÖÄÚ²¿ÁªÏµ±äµÃºÜÉÙ,´ó´óÔ¼ÊøÁËËüµÄ¹¦ÄÜ,±ÈÈçÓëһЩӲ¼þÉ豸ͨÐÅ,ÍùÍùÒª»¨·ÑºÜ´óµÄ¾«Á¦È¥Éè¼ÆÁ÷³Ì±àд´úÂëÈ¥¹ÜÀíÉ豸¶Ë¿Ú,¶øÇÒÓÐһЩÉ豸³§ÉÌÌṩµÄÓ²¼þ½Ó¿ÚÒѾ¾¹ýÒ»¶¨µÄ·â×°ºÍ´¦Àí,²»ÄÜÖ±½ÓʹÓÃjava³ÌÐòͨ¹ý¶Ë¿ÚºÍÉè±¸Í ......
File f=new File("DerectoryName");
String []results=f.list();
import java.io.*;
¡¡¡¡public class listFile
¡¡¡¡{ &nb ......