Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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>
<


Ïà¹ØÎĵµ£º

´ÓJCOµ½SAPµÄIDOCµÄxml¸ñʽ

      <?xml version="1.0"?>
    <BANK_CREATE01>  
        <IDOC BEGIN="1">   
            <EDI_DC40 SEGMENT=" ......

ÓÃVC++2005¶ÁXMLÎļþµÄСÀý×Ó

 1¡£Ð´Ò»¸öxmlÎļþ
 
 <?xml version="1.0" encoding="utf-8" ?>
- <root>
- <user id="101">
<name>abc</name>
<password>abc</password>
</user>
- <user id="102">
<name>ccc</name>
<password>ccc< ......

½éÉÜ.NET XMLÐòÁл¯£¬¹¹½¨XMLÐòÁл¯µÄ¿ò¼ÜÀà

Ò»¡¢±¾ÕÂÖ÷Òª½éÉÜ.NET XMLÐòÁл¯£¬¹¹½¨XMLÐòÁл¯µÄ¿ò¼ÜÀ࣬Ö÷Òª·ÅÔÚÄãµÄ¿ò¼ÜÏîÄ¿ÀïÃ棬ÀàÃû×ÖÃüÃûΪSerialiser£¬ÎҵĿò¼ÜÏîÄ¿Ãû³ÆÊÇMingXu.FrameWork£¬ÎÒ½«Serialiser·Åµ½ËüÏÂÃ棬MingXu.FrameWorkÀàÐÍΪClass Library
 
¶þ¡¢ÐòÁл¯ÀàÓõ½ÁË2¸ödll£¬·Ö±ðΪ£º
     System.Xml.Serialization£ºX ......

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

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

ÓÃJAXB´æÈ¡XMLÊý¾Ý

JAXB¸ÅÒª
JAXBΪJava Architecture for XML BindingµÄËõд£¬ÒâΪXML°ó¶¨µÄJAVA¿ò¼Ü¡£ËüÌṩÁËÒ»Ì׿ÉÒÔ¼òµ¥´æÈ¡XMLÊý¾ÝµÄAPI£¬Í¬Ê±£¬JAXB¿ÉÒÔ¸ù¾ÝXMLµÄschema×Ô¶¯Éú³É²Ù×÷XMLµÄJAVAÀà¡£ÀûÓÃJAXB£¬Ê¹ÓÃJAXB×Ô¶¯Éú³ÉµÄ²Ù×÷XMLµÄJAVAÀ࣬¿ÉÒÔ»ù±¾Éϲ»Óÿ¼ÂÇXML½á¹¹¶ø¼òµ¥µØ´æÈ¡XMLÊý¾Ý¡£
JAXBµÄÏÂÔØÓë°²×°
JAXBÖÁÉÙÐèÒªµ¼ÈëÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ