Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

XStream ·Ç³£¼òµ¥ÊµÓõÄXML¶Áд¹¤¾ß(Ò»)

×î½ü¹¤×÷ÄÚÈÝÐèÒª¶ÔJava¶ÔÏó×öXMLÊä³ö£¬¹«Ë¾Àï³£ÓõÄÁ½ÖÖ¿ò¼ÜÊÇXStreamºÍXML Beans¡£Á½ÖÖ¶¼ÎÒ¶¼ÓÃÁË£¬¶ÔÓÚÆÕͨµÄ£¬schema²»ÊǺܸ´ÔÓµÄXMLÎļþÀ´ËµÑ¡ÔñXStream¸ü·½±ã¡£ÕâƪÎÄÕÂÏȽéÉÜÒ»ÏÂXStreamµÄÓ÷¨£¬XML BeansµÄÓ÷¨ÁíÍâÔÙ½éÉÜ¡£
1. Ïȸø¸öÒªÊä³öµÄxmlÎĵµµÄÀý×Ó£º
<students>
<student>
<name>Peter</name>
<id>1001</id>
<age>15</age>
<student>
<student>
<name>Mike</name>
<id>1002</id>
<age>16</age>
<student>
<students>
2. Ê×Ïȶ¨ÒåÁ½¸öÀࣺStudentsºÍStudent£¬ÆäÖÐStudentsÓÐÒ»¸öList<Student>£¬StudentÓÐÈý¸öField£ºname£¬id£¬age
public class Students {

List studentList;

public Students() {
studentList = new ArrayList();
}
public void addStudent(Student p) {
studentList.add(p);
}
}
public class Student {
private String name, id, age;
public Student(String name, String id, String age){
this.name = name;
this.id = id;
this.age = age;
}
//Setter and Getter for name, id, age
......
}
3. ʹÓÃXStream½«ObjectдÈëXML£º
//XStreamʵÀý
XStream xStream = new XStream();
//¶¨ÒåxmlµÄ¸ù½Úµã"Students"
Students root = new Students();
//¶¨Òå¸ù½ÚµãµÄÁ½¸ö×Ó½Úµã"Student"
Student peter = new Student("peter", "1001", "15");
Student mike = new Student("mike", "1002", "16");
//Ìí¼Óµ½¸ù½ÚµãÉÏ
root.addStudent(peter);
root.addStudent(mike);
//
System.out.println(xStream.toXML(root));
4. Êä³öµÄ½á¹ûºÍÎÒÃǵÄÆÚ´ýµÄ²¢²»ÍêÈ«Ò»Ñù£º
<de.dexin.student.Students>
<studentList>
<de.dexin.student.Student>
<name>peter</name>
<id>1001</id>
<age>15</age>
</de.dexin.student.Student>
<de.dexin.student.Student>
<name>mike</name>
<id>1002</id>
<age>16</age>
<


Ïà¹ØÎĵµ£º

XmlÖеĽڵã»òÊôÐÔֵȥ¿Õ°×

<Records>
<Record>
<id>1 </id>
<name>ÀîËÄ </name>
</Record>
<Record>
<id>2 </id>
<name>ÕÅÈý </name>
</Record>
<Record>
<id>3 </id>
<name>ÍõÎå </name>
</Record& ......

XMLÓëCSS IDÑ¡Ôñ·ûµÄʹÓÃ

ID.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="ID.css"?>
<bookdetail>
<book class="A" id="B1">
<author>²ÜÑ©ÇÛ</author>
<title>ºìÂ¥ÃÎ</title>
<price>60.00</price>
</book>
<book class="A ......

¹ØÓÚHTTP·ÃÎÊXMLÎļþµÄËæ±Ê

×î½üÏîÄ¿ÖÐÒªÓõ½Ò»Ð©web xmlÊý¾ÝµÄ·ÃÎÊ·ÖÎö£¬²ÉÓÃmsxml
1.msxmlÊÇ΢ÈíÌṩµÄ£¬ÔÚ·Ç¿ª·¢»·¾³ÖУ¬ÐèҪע²á
2.xmlÎļþ£¬Ò»°ãÔÚµÚÒ»¾äÓбàÂ뷽ʽ£¬Ò»°ãĬÈÏÊÇutf-8£¬ÊôÓÚÒ»ÖÖunicode
3.´ÓÍøÂç²É¼¯µÄxmlÊý¾Ý£¬ÐèҪʹÓÃwinnetº¯Êý¿â
4.winnet²É¼¯×ÔÍøÂçµÄÊý¾Ý£¬Ä¬ÈϵĶ¼ÊÇCP_ACP¸ñʽµÄ£¬¼òµ¥Ëµ¾ÍÊÇANSI»òUNICODE£¬UTF8µÄ±àÂë ......

ÔÚasp.netÖжÔXMLÎĵµ½øÐеIJÙ×÷£¨²»È«£¬´ýÐø£©

¶ÁXMLÎļþ
DataSet books = new DataSet();
books.ReadXml(MapPath("booklist.xml"));
booklist.DataSource = books;
booklist.DataBind(); ......

Ajax£ºÓµ±§JSON£¬ÈÃXML×ß¿ª


Ajax(Asynchronous JavaScript and XML)˵µ½µ×¾ÍÊÇÒ»ÖÖä¯ÀÀÆ÷Òì²½¶ÁÈ¡·þÎñÆ÷ÉÏXMLÄÚÈݵļ¼Êõ¡£ÏÖÔڵļ¼Êõ·²ÊǸúXML³¶ÉϹØϵ£¬ÔÙ¼ÓÉϸö¸ÅÄî×ö»Ï×Ó£¬¾ÍÏñ½ð×°ÁËÒ»Ñù£¬×§µÃ²»ÐС£ÃÅÍâ µÄÈË¿´µÃºÜÊÇÈÈÄÖ£¬ÃÅÀïµÄÈËÒ¡Ò¡Í·²»ÍâÈçÊÇ¡£XMLÄØ£¬¿çƽ̨µÄг±ÓïÑÔ£¿ÆäʵXML£½TXT¡£
XMLÖ»ÊÇ·ûºÏºÜ¶à¹æ·¶µÄÎı¾¡£Ëü±¾Éíʲô¶¼²»ÊÇ£¬Ö ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ