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
Ïà¹ØÎĵµ£º
// MsXmlTest.cpp : ¶¨Òå¿ØÖÆ̨ӦÓóÌÐòµÄÈë¿Úµã¡£
//
#include "stdafx.h"
#include "MsXmlTest.h"
#include <clocale>
#include "comutil.h"
#import "msxml4.dll"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// ΨһµÄÓ¦ÓóÌÐò¶ÔÏó
CWinApp theApp;
using namespace std;
void WritePerson(MSXML2: ......
Integration with the XML Data Type
With the introduction of the XML data type, we wanted to also give FOR XML the ability to generate an instance of XML directly (more precisely, it generates a single row, single column rowset where the cell contains the XML data type instance).
Because of the bac ......
Flex ºÍC++ Ö®¼ä´«Êä½á¹¹ÌåÊý¾Ý
Ò»Ö±ÏëÊÔÑéÓýṹÌå´«Êý¾Ý
µ«ÊÇFlex ºÍC++ µÄÀàÐÍËùÕ¼µÄ×Ö½ÚÊýÓÐʱ²»Ò»Ñù
Èçint ÔÚC++ÖÐÕ¾2¸ö×Ö½Ú£¬¶øÔÚFlexÖÐÕ¼4¸ö×Ö½Ú¡£
ת»»±È½ÏÂé·³¡£
×îºó¾ö¶¨ÓÃXML½øÐд«Êä
È»ºóÁ½±ß¶¼¼ÓÒ»¸öXML ½âÎöºÍ·â×°Àà¡£
C++ ¶ËʹÓõÄtinyXML Àà
FlexÖ±½ÓʹÓÃ×Ô¼º´øµÄ E4X Àà
Flex´úÂëÈçÏÂ
&nb ......
ÔںܶàÑÐÌÖ»áºÍÅàѵ°àÉÏÎÒÓöµ½¹ýÐí¶àÈË£¬ËûÃÇ»¹²»Ã÷°×ΪʲôҪʹÓÃXMLÒ²²»ÖªµÀÈçºÎÔÚËûÃǵÄÓ¦ÓÃÖÐʹÓÃXML¡£Ò»Ð©À´×ÔÖîÈçGartner¹«Ë¾µÄ±¨¸æ½¨Òé˵£¬ÉÌÒµ¹«Ë¾²»ÄÜÔÙ×ö¾ÖÍâÈËÁË£¬²»ÄܶÔXMLÖÃÖ®²»Àí¡£Èç¹ûÄ㻹²»Çå³þXMLµ½µ×ÓÐʲôºÃ´¦µÄ»°£¬Äã²¢²»ÊÇΨһµÄÈË¡£
ÎÒ¾ö¶¨°ÑÓëÈËÃǺÍýÌå¹ØÓÚXML»°ÌâµÄ½»Ì¸ÕûÀí³ÉÎÄ£¬ÁгöXMLÔÚÓ¦ÓÃÖ ......