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

StrutsÖÐÀûÓÃactionÀ´Êä³öxmlÎļþ

      Ó¦Ò»¸öͬʵÄÒªÇó£¬ÒªÀûÓÃstrtusµÄAction½«Ò»¸öÊý¾Ý¿â±íµÄÊý¾ÝÊä³öΪxml¸ñʽµÄÊý¾Ý£¬·½±ãµ¼ÈëʹÓ᣾­Ñо¿Action»¹ÕæÄÜ°ìµ½£¬Êµ¼ÊÉϲ»ÊÇActionµÄ¹¦ÀÍ£¬¶øÊÇJDOMµÄ¹¦ÀÍ£¬²»ËµÄÇô¶àÁË£¬¸ø´ó¼Ò·ÖÏíһϡ£     ÎÒÓÐÒ»¸ö²âÊÔ±í£¬ÓÐÁ½¸ö×ֶΣ¬Ò»¸öÊÇÓû§Ãû£¬Ò»¸öÊÇÃÜÂ룬ÏÖ½«Õâ¸ö±íµÄÊý¾ÝÈ«²¿Êä³öΪxml¸ñʽµÄ¡£Ê×Ïȸø³öÎÒµÄAction£¬´úÂëÈçÏ£º package com.yourcompany.struts.action;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
import com.yourcompany.struts.form.User;
public class DisplayALL extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
DataSource ds = getDataSource(request, "s9");
Connection conn = ds.getConnection();
Statement stmt = null;
ResultSet rs = null;
response.setContentType("text/xml;charset=utf-8");
Element rootElement = new Element("users");
Document users = new Document(rootElement);
try {
String ls_sql = "select * from dd ";
stmt = conn.createStatement();
rs = stmt.executeQuery(ls_sql);
while (rs.next()) {
Element user = new Element("user");
user.setAttribute("username", rs.getString(1));
user.setAttribute("password", rs.getString(2));
rootElement.addContent(user);
}
XMLOutputter xout=new XMLOutputter();
xout.output(users,response.getWriter());
} c


Ïà¹ØÎĵµ£º

DataSet¡¢Excel¡¢XMLÖ®¼äµÄµ¼Èëµ¼³ö

class ImportExportToExcel
{
public class ImportExportToExcel
{
private string strConn;
private System.Windows.Forms.OpenFileDialog openFileDlg = new System.Windows.Forms.OpenFileDialog();
private System.Windows.Forms.SaveFileDialog saveFi ......

Êý¾Ý¿â²éѯXML½á¹¹£¬FOR XML PATH Óï¾äµÄÓ¦ÓÃ


/*
Êý¾Ý¿â²éѯXML½á¹¹£¬FOR XML PATH Óï¾äµÄÓ¦ÓÃ
*/
FOR XML PATH Óï¾äµÄÓ¦ÓÃ:
CREATE  TABLE TempTable(UserID int , UserName nvarchar(50));
insert into TempTable (UserID,UserName) values (1,'a')
insert into TempTable (UserID,UserName) values (2,'b')
select UserID,UserName from TempTable FOR ......

xmlºÍjava BeanµÄÖ±½Óת»»£¬Xmap

package test;
import java.util.ArrayList;
import java.util.List;

import org.nuxeo.common.xmap.annotation.XNode;
import org.nuxeo.common.xmap.annotation.XNodeList;
import org.nuxeo.common.xmap.annotation.XObject;


/**
* Book ʵÌå¶ÔÏ󣬴˴¦ÓÃXMap×¢½â
* @author Administra ......

Java²Ù×÷XMLÎļþ dom4j ƪ£¨×ªÔØ£©


ÔÚÏîÄ¿ÖУ¬ÎÒÃǺܶ඼Óõ½ÁËxmlÎļþ£¬ÎÞÂÛÊDzÎÊýÅäÖû¹ÊÇÓëÆäËüϵͳµÄÊý¾Ý½»»¥¡£
½ñÌì¾ÍÀ´½²Ò»ÏÂJava ÖÐʹÓÃdom4jÀ´²Ù×÷XMLÎļþ¡£
ÎÒÃÇÐèÒªÒýÈëµÄ°ü£º
//Îļþ°ü
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
//¹¤¾ß°ü
import java.util.Ite ......

J2MEÖÐKXMLÓëNanoXML½âÎöXML×ܽá

ÔÚJ2MEÌåϵÖУ¬¶ÔxmlµÄ½âÎöÓбȽÏÓÐÃûµÄµÚÈý·½½âÎöAPI£¬·Ö±ðΪKXMLºÍNanoXML£¬ËûÃǶ¼ÌṩÁ˶ԽâÎöxmlµÄÖ§³Ö¡£KXMLÔÚ½âÎöXML¹ý³ÌÖлá¶ÔÎļþÄÚÈÝÒ»²ãÒ»²ã½øÐнâÎö£¬Òò´Ë³ÉΪÔöÁ¿Ê½½âÎöÆ÷£¬±È½ÏÊʺϴóÎļþµÄ½âÎö¡£¶øNanoXMLÊÇÒ»´ÎÐÔ½âÎöÆ÷£¬ÔÚÒ»´Îʱ¼äÀï¾Í°ÑÕû¸öxmlÎĵµ½âÎöÍ꣬Òò´Ë²»ÊʺϴóÎļþµÄ½âÎö£¬»áÔì³ÉÄÚ´æ²»×ãµÄÏÖÏó¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ