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

ʹÓà XStreamʵÏÖJavaBean Óë XML/JSON Ö®¼äÏ໥ת»»

XML ºÍ JSON Êǵ±½ñ³£ÓõÄÁ½ÖÖÊý¾ÝÃèÊöÓë´«ÊäµÄ¸ñʽ£¬ÌرðÊÇÉæ¼°µ½ JS ʱʹÓà JSON ÆÄΪƵ·±¡£×ÔÈ»£¬ÔÚ Java  µÄÊÀ½çÀïÉÙ²»ÁËÍê³É JavaBean ÓëÕâÁ½ÖÖ¸ñʽÏ໥ת»»µÄ×é¼þ£¬ÄǾÍÊÇ XStream ºÍ JSON-lib¡£ÕâÀïÎÒ¼òµ¥¼ÇÏ XStream  µÄÓ÷¨¡£
ÆäʵÏàÀàËƵŤ¾ßÔçÒÑÓÐÖ®¡£Èç¹ûÓùý DWR µÄͬ־£¬Ò»¶¨ÓÐÓ¡Ïñ£¬DWR ½øÐÐÔ¶³Ì·½·¨µ÷ÓÃʱҲÄÜΪÄãÍê³É JavaBean ºÍ JSON ¸ñʽµÄË«Ïòת»»µÄ£¬ËùÒÀÀµµÄÊÇËüµÄ¸÷ÖÖ Converter¡£ÔÙÒªÊÇ¶Ô Struts1 µÄϸ½ÚÓÐËù×¢ÒâµÄ»°£¬Struts1 µÄ ActionServlet ÔÚ³õʼ»¯ struts-config.xml ʱÊÇͨ¹ý commons-digester À´Íê³É XML µ½ JavaBean ת»»µÄ¡£ÏàÓ¦µÄ Apache Ò²ÓÐÒ»¸ö commons-betwixt ʵÏÖÁË JavaBean µ½ XML µÄÉú³É¡£
¶øÎÒÕâÀïҪ˵µÄ XStream(http://xstream.codehaus.org) °Ñ JavaBean Óë XML/JSON ¼äµÄË«Ïòת»»Í³Í³ÊµÏÖÁË£¬¶ø JSON-lib ÔòÈçÆäÃû£¬¹¦ÄÜÌ«ÏÔ¼òªÁË¡£ÒªÊ¹Óà XStream£¬ÐèÏÂÔص½ xstream°ü£¬µ±Ç°°æ±¾ÊÇ 1.3.1¡£È»ºó°Ñ xstream-1.x.x.jar Ìí¼Óµ½ÏîÄ¿µÄ Classpath ÉÏ£¬¿É²»ÒÀÀµÓÚÆäËû°ü¡£ÔÚijЩÓÐÒªÇóʱºò²ÅÐèÒªÓõ½ lib Ŀ¼ÖеÄÆäËû°ü£¬ÏÂÃæ»áÌáµ½¡£
¼òµ¥ËµÃ÷ XStream µÄʹÓðɣ¬·ÖΪ JavaBean -> XML¡¢JavaBean -> JSON¡¢ XML -> JavaBean¡¢JSON -> JavaBean ¼¸²¿·ÖÄÚÈÝ¡£ÔÚ¿ªÊ¼Àý×Ó֮ǰ£¬Ïȶ¨ÒåÈý¸öÀà(¶¼ÔÚ com.unmi.model °üÖÐ)£º
public class Customer {   
    private int custId;   
    private String custName;   
    private List<Order> orders;   
    //setter/getter ºÍ¹¹Ôì·½·¨ÂÔ   
}   
  
public class Order {   
    private int orderId;   
    private String orderName;   
    private Product[] products;   
    //setter/getter ºÍ¹¹Ôì·½·¨ÂÔ   
}   
  
public class Product {   
    private int prodId;  


Ïà¹ØÎĵµ£º

flash xml ÍêÃÀ½â¾öÖÐÎÄÏÔʾ ת


´ó¼ÒÓ¦¸Ã¶¼ä¯ÀÀ¹ýºÜ¶àflashÕûÕ¾Ô´Â룬flash½áºÏxml´ïµ½Ò»¸ö¶¯Ì¬ÐÞ¸ÄflashÊä³öÄÚÈݵÄЧ¹û£¬ÓÃflashÀ´ÌåÏÖÒ»¸öÍøÕ¾£¬²¢ÇÒÄܼòµ¥µÄ¶¯Ì¬¸üУ¬´ó¶¼ÕâЩԴÂëÊÇÀÏÍâ·Å³öÀ´µÄ£¬ÔÚÊäÈëÊä³ö·½Ã棬¼¸ºõ¶ÔÖÐÎĶ¼²»Ö§³Ö£¬ºÜ¶àºÜìŵÄЧ¹û
ÎÒÃÇÈÏʶ·½¿é×ÖµÄÈ˶¼Óò»ÁË£¨Í»È»¸ÐÎò£¬¼ÆËã»ú´øÀ´µÄ¿Æ¼¼¸ïÃü£¬ÎªÊ²Ã´²»»áÊÇÖйúÈËÄØ£¿¶øÊÇÖ»Ó ......

c# txtÎı¾×ªxmlÎı¾

       ÏÖÔںܶàÈí¼þ¶¼ÊÇÒÔxmlÎļþ×÷ΪÊý¾ÝÔ´£¬¶øºÜ¶àÊý¾Ý¹¤¾ßÈçpbµÈÈ´Ö»ÄÜÁí´æΪtxt¡¢excelµÈ¸ñʽ£¬Îª´ËÐèÒªÒ»¹¤¾ßÄܽ«txtÎı¾×ª»»³ÉxmlÎļþ¡£googleÁËһϣ¬Ã»ÕÒµ½ºÏÊʵģ¬³å¶¯Ö®ÏÂÓÃC#дÁËÒ»¸ötxtÎı¾×ªxml¸ñʽÎı¾µÄС³ÌÐò£¬´úÂëÈçÏ¡£
       н¨Ò»¸öw ......

JSP/XML,JavaBeanºÍCSS/XSLЭͬ¹¤×÷

1.ÔÚJSPÖÐÉú³É¶¯Ì¬XML
  ¿ÉÒÔʹÓÃJSPÉú³ÉXML,ʹÓÃCSS»òÕßXSLת»»ºÍÏÔʾXML;
  Ö»ÒªÔÚ¾²Ì¬µÄXMLÎĵµÄ£°åÖмÓÈëJava´úÂëºÍJSP±ê¼Ç£¬XML¾Í¿ÉÒÔÓо²±ä¶¯£¬²úÉú¶¯Ì¬µÄÄÚÈÝ£¬Éú³ÉXMLÎĵµµÄ·½·¨ºÜ¼òµ¥£¬Ö»ÐèÒªÔÚÎļþÖÐʹÓÃÖ¸Áîcontenttype,Èç<%@ page contenttype="text/xml"%>£»
  ÔÚXMLÎĵµÖÐͬÑù¿ÉÒÔʹ ......

C++ϵÄXML·ÖÎö¹¤¾ßCMarkup

1¡¢³õʼ»¯
Load µ¼ÈëÒ»¸öXMLÎļþµ½CMarkupµÄ¶ÔÏóÖУ¬²¢¶ÔËü½øÐнâÎö¡£ÀàËÆC#µÄLoad¡£
SetDoc ´Ó×Ö·û´®Öе¼ÈëXMLÊý¾Ý£¬²¢¶ÔËü½âÎö¡£ÀàËÆC#µÄLoadXml¡£
2¡¢Êä³ö
Save ½«XMLÊý¾ÝдÈëÎļþÖС£ÀàËÆC#µÄSave¡£
GetDoc ½«Õû¸öXMLÊý¾ÝÎĵµ×÷Ϊ×Ö·û´®·µ»Ø¡£
3¡¢¸Ä±äµ±Ç°Î»ÖÃ
FindElem ¶¨Î»µ½ÏÂÒ»¸öÔªËØ£¬¿ÉÄܺÍÒ»¸ö±êÇ©Ãû»ò· ......

DataSet(DataTable)ÓëXML»¥×ª

using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Text;
// ÏàÓ¦C#´úÂ룺
private string ConvertDataTableToXML(DataTable xmlDS)
{
MemoryStream stream = null;
XmlTextWriter writer = null;
try
{
stream = new MemoryStream();
writer = new XmlTextWriter(stream, E ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ