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
Ïà¹ØÎĵµ£º
JAVA¶ÔÏóת»»ÎªXML¸ñʽ
¼òµ¥µÄ²üÊöÏÂÈçºÎ½«JAVA¶ÔÏóת»»ÎªXML¸ñʽ£¬ÏêϸÁ˽âÇë½øÈëhttp://xstream.codehaus.org/tutorial.html
JAVABEAN¶ÔÏó
userInfo.java
private String name;
& ......
string GetXmlByDataTable()
{
string xmlstr;
string sql = "select top 10 * from BasicInfo";
DataTable dt = idb.ReturnDataTable(sql);
&nb ......
תÔØ×Ô£ºhttp://virgos.javaeye.com/blog/611146
Ò»£®Ç°ÑÔ£º
XMLÊÇ΢Èí.NetÕ½ÂÔµÄÒ»¸öÖØÒª×é³É²¿·Ö£¬¶øÇÒËü¿ÉνÊÇXML Web·þÎñµÄ»ùʯ£¬ËùÒÔÕÆÎÕ.Net¿ò¼ÜϵÄXML¼¼Êõ×ÔÈ»ÏԵ÷dz£ÖØÒªÁË¡£±¾ÎĽ«Ö¸µ¼´ó¼ÒÈçºÎÔËÓÃC#ÓïÑÔÍê³É.Net¿ò¼ÜϵÄXMLÎĵµµÄ¶Áд²Ù×÷¡£Ê×ÏÈ£¬ÎÒ»áÏò´ó¼Ò½éÉÜ.Net¿ò¼ÜÖÐÓëXMLÏà¹ØµÄÃüÃû¿Õ¼äºÍÆäÖеÄÖØÒªÀ ......
Ñо¿E4XÓëFlexµÄ¹Øϵ£¬ËùÒÔ´òËã×ܽáһϣ¬ÓÐ˵µÄ²»¶ÔµÄµØ·½£¬»¹Çë´ó¼Ò¶à¶àÔÁ¡£
Ò»¡¢×î¼òµ¥Ä£Ê½£ºFlexͨ¹ýhttpserviceºÍdataProvider½øÐÐÊý¾Ý´«Êä
Xml¸ñʽÈçÏ£º
<?xml version="1.0" encoding="utf-8" ?>
<Result>
<NodeA>value1</NodeA>
<NodeB>valve2</NodeB>
…&he ......
±¾ÎĹ²Á½¸öÎļþ£ºtranslate.mxml ºÍ mapmarking.xml
1¡¢translate.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="librar ......