ÓÃjdomʵÏÖ½«Êý¾Ý¿â×ÊÁÏÉú³ÉxmlÎļþ
½ñÌìµÄÏîÄ¿Ä£¿éÖÐÓõ½¸ù¾ÝÊý¾Ý¿âÀïµÄ×ÊÁÏÉú³ÉxmlÎļþ£¬Ö÷Òª²½ÖèÈçÏ£º
£¨1£© Á¬½ÓÊý¾Ý¿â£¬È¡³öÊý¾Ý£»
£¨2£© ´´½¨½áµã£¬Ìí¼Ó×ÓÏ
£¨3£© дÈëÎļþ“test.xml”ÖУ»
¾ßÌå´úÂëÈçÏ£º
import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
public class CreateXml {
/**
* @param args
* @throws ClassNotFoundException
* @throws SQLException
*/
public static void main(String[] args) throws ClassNotFoundException,SQLException {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/lalayi?user=root&password=root");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from store");
try {
Element root = new Element("µêÃæÀà");
Document Doc = new Document(root);
int i = 0;
while (rs.next()) {
Element elements = new Element("µêÃæ");
elements.addAttribute("id","" + i);
elements.addContent(new Element("µêÃæID").setText(rs.getString(1)));
elements.addContent(new Element("Ãû³Æ").setText(rs.getString(2)));
elements.addContent(new Element("ÃÜÂë").setText(rs.getString(3)));
elements.addContent(new Element("ÓÊÏä").setText(rs.getString(4)));
elements.addContent(new Element("ÈÕÆÚ").setText(rs.getString(5)));
elements.addContent(new Element("ÊÖ»ú").setText(rs.getString(6)));
elements.addContent(new Element("ÊÖ»ú2").setText(rs.getString(7)));
&nbs
Ïà¹ØÎĵµ£º
ÓÃTXT±à¼ÁËÒ»¸öXMLÎĵµ
<?xml version="1.0" encoding="utf-8"?>
<TEST>"
<Test Value="ÕâÊÇÒ»¸ö²âÊÔ" />
</TEST>
ÓÃIE´ò¿ªµÄʱºòÒ»Ö±ÏÔʾÓдíÎó£¬ÏÔʾººÓï×Ö·û²»Ö§³Ö¡£
¸ÄΪencoding=“gb2312”ºóÏÔʾÕý³£ÁË¡£
µ«Õâ¸ö½á¹ûÓë³õÖÔÎ¥±³£¬ÒòΪUTF-8ÊÇÖ§³ÖËùÓÐÓïÑԵġ£
ºóÀ´²éÕÒÔÒ ......
gloox×Ô¼ºÊµÏÖÁËxmlµÄ½âÎöÄ£¿é£¬Ã»ÓÐÓõ½µÚÈý·½µÄ¿â(tinyXML£¬expat )
Ö÷ÒªÉæ¼°µÄÎļþ:
tag.h (tag.cpp)
taghandler.h
parser.h (parser.cpp)
1. TagÒ»¸öTag¾ÍÊÇÒ»¸öXMLÔªËØ
ÀýÈç:
a.
<book kind='computer'>
<store id='23'/>
<author>
qiang
</author>
</bo ......
XML£¨Extensible Markup Language£©¼´¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ£¬ËüÓëHTMLÒ»Ñù£¬¶¼ÊÇSGML(Standard Generalized Markup Language,±ê׼ͨÓñê¼ÇÓïÑÔ)¡£XmlÊÇInternet»·¾³Öпçƽ̨µÄ£¬ÒÀÀµÓÚÄÚÈݵļ¼Êõ£¬Êǵ±Ç°´¦Àí½á¹¹»¯ÎĵµÐÅÏ¢µÄÓÐÁ¦¹¤¾ß¡£À©Õ¹±ê¼ÇÓïÑÔXMLÊÇÒ»ÖÖ¼òµ¥µÄÊý¾Ý´æ´¢ÓïÑÔ£¬Ê¹ÓÃһϵÁмòµ¥µÄ±ê¼ÇÃèÊöÊý¾Ý£¬¶øÕâЩ±ê¼Ç¿ÉÒÔÓà ......
ʲôÊÇ XML£¿
¡¡¡¡¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ (XML) ÊÇ Web ÉϵÄÊý¾ÝͨÓÃÓïÑÔ¡£Ëüʹ¿ª·¢ÈËÔ±Äܹ»½«½á¹¹»¯Êý¾Ý£¬´ÓÐí¶à²»Í¬µÄÓ¦ÓóÌÐò´«µÝµ½×ÀÃ棬½øÐб¾µØ¼ÆËãºÍÑÝʾ¡£XML ÔÊÐíΪÌض¨Ó¦ÓóÌÐò´´½¨Î¨Ò»µÄÊý¾Ý¸ñʽ¡£Ëü»¹ÊÇÔÚ·þÎñÆ÷Ö®¼ä´«Êä½á¹¹»¯Êý¾ÝµÄÀíÏë¸ñʽ¡£
¡¡¡¡Ê²Ã´ÊÇ MSXML£¿
¡¡¡¡MSXML ÊÇÌṩºËÐÄ XML ·þÎñµÄ Microsoft Èí ......
×î½üÔÚÏîÄ¿ÖÐÓöµ½flex¿çÓò·ÃÎʵݲȫɳÏäÎÊÌ⣬²é×ÊÁÏÁ˽⵽ÐèÒªÔÚ·þÎñ¶Ë¼ÓÉÏcrossdomain.xmlÎļþ£¬¼´£º
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-do ......