dom4j¶Ôxml±È½ÏÍêÕûµÄ²Ù×÷
×î½üдµÄ²å¼þÓõ½ÁËdom4j£¬À´¶Áд£¬ÐÞ¸ÄÎĵµ¡£Óõ½µÄ¹¦Äܶ¼Ð´³öÀ´ÁË
ÏÂÃæ°üº¬ÁËÁ½¸ö³ÌÐò WriteFriendsInfo£¬ºÍ ReadFriendsInfo¡£
1.WriteFriendsInfo °üº¬ÁËн¨xmlºÍÐ޸ģ¬É¾³ýxml½ÚµãµÄ·½·¨
һЩҪµã£º
WriteFriendsInfo ÖÐÐ޸Ľڵã²ÉÓõķ½Ê½ÊÇɾ³ý½Úµã£¬È»ºó°ÑеĽڵãд½øÈ¥¡£ÔÚ²»¶Ô¶ÁдҪÇóºÜ´óµÄÇé¿öÏ£¬ÕâÑù×ö±È½Ï¼òµ¥¡£
»¹ÓоÍÊÇÖÐÎĵĶÁдÎÊÌ⣺
дÈë´øÖÐÎÄµÄ Document µ½xmlÎı¾
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
output = new XMLWriter(new FileWriter(new File("/kb2.xml")),format);
¶Á´øÖÐÎĵÄxmlÎı¾£º
ÎÒÔÀ´ÊÇÕâôдµÄ£ºdocument = saxReader.read(new File("/kb2.xml"));
½á¹ûÒ»Óöµ½ÖÐÎľͱ¨´í£¬ÓÃFileReader¿ÉÒÔÃâÈ¥ºÜ¶à×Ö·ûÎÊÌ⣺
FileReader fr= new FileReader(new File("/kb2.xml"));
document = saxReader.read(fr);
2.ReadFriendsInfo µÄ×÷ÓÃÊǶÁxmlÊý¾Ý·ÅÈë×Ô¶¨ÒåµÄÊý¾Ý½á¹¹¡£
¶Á½ÚµãºÜ¼òµ¥³ä·ÖÌåÏÖÁË dom4jµÄÖÇÄÜ»¯
package com.soulnew.netbeansmessage;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import java.io.*;
import java.util.Iterator;
import java.util.List;
import org.dom4j.io.OutputFormat;
public class WriteFriendsInfo{
String filename="/kb2.xml";
public void setFilename(String filename) {
&nbs
Ïà¹ØÎĵµ£º
/*
Êý¾Ý¿â²éѯ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 ......
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 ......
×Ý×ø±êºº×Ö˵Ã÷ yAxisName='̨' rotateYAxisName='0'
FusionCharts µÄ XML±êÇ©ÊôÐÔÓÐÒ»ÏÂËÄÖÖÊý¾ÝÀàÐÍ
* Boolean - ²¼¶ûÀàÐÍ£¬Ö»ÄÜΪ1»òÕß0¡£ÀýÈ磺<graph showNames=’1′ >
* Number - Êý×ÖÀàÐÍ£¬Ö»ÄÜΪÊý×Ö¡£ÀýÈ磺<graph yAxisMaxValue=’200′ >
* String - ×Ö·û´®ÀàÐÍ£¬Ö ......
ÔÚJ2MEÌåϵÖУ¬¶ÔxmlµÄ½âÎöÓбȽÏÓÐÃûµÄµÚÈý·½½âÎöAPI£¬·Ö±ðΪKXMLºÍNanoXML£¬ËûÃǶ¼ÌṩÁ˶ԽâÎöxmlµÄÖ§³Ö¡£KXMLÔÚ½âÎöXML¹ý³ÌÖлá¶ÔÎļþÄÚÈÝÒ»²ãÒ»²ã½øÐнâÎö£¬Òò´Ë³ÉΪÔöÁ¿Ê½½âÎöÆ÷£¬±È½ÏÊʺϴóÎļþµÄ½âÎö¡£¶øNanoXMLÊÇÒ»´ÎÐÔ½âÎöÆ÷£¬ÔÚÒ»´Îʱ¼äÀï¾Í°ÑÕû¸öxmlÎĵµ½âÎöÍ꣬Òò´Ë²»ÊʺϴóÎļþµÄ½âÎö£¬»áÔì³ÉÄÚ´æ²»×ãµÄÏÖÏó¡ ......