ÔõÑù½«XMLµÄDocument ת»»³É String
import java.io.StringWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.apache.xerces.dom.DocumentImpl;
import org.apache.xerces.dom.DOMImplementationImpl;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.Serializer;
import org.apache.xml.serialize.XMLSerializer;
public class HelloApache
{
public static void main (String[] args)
{
try
{
Document doc = new DocumentImpl();
// Create Root Element
Element root = doc.createElement("BOOK");
// Create 2nd level Element and attach to the Root Element
Element item = doc.createElement("AUTHOR");
item.appendChild(doc.createTextNode("Bachelard.Gaston"));
root.appendChild(item);
// Create one more Element
item = doc.createElement("TITLE");
item.appendChild(doc.createTextNode
("The Poetics of Reverie"));
root.appendChild(item);
item = doc.createElement("TRANSLATOR");
item.appendChild(doc.createTextNode("Daniel
Russell"));
root.appendChild(item);
// Add the Root Element to Document
doc.appendChild(root);
//Serialize DOM
OutputFormat format = new OutputFormat (doc);
// as a String
StringWriter stringOut = new StringWriter (); &nb
Ïà¹ØÎĵµ£º
ͨ¹ýJOXÇáËÉʵÏÖJavaBeansÓëXMLµÄÏ໥ת»»
JOXʹµÃÔÚXMLÎĵµÓëJava BeansÖ®¼ä½øÐÐÊý¾Ýת»»±äµÃÈÝÒ×.Äã¿ÉÒÔÀûÓÃJOXÀ´½«¶ÔÏóÐòÁл¯µ½XML.
¿ª·¢ÓïÑÔ£º Java
²Ù×÷ϵͳ£º
Èí¼þÖ÷Ò³£º http://www.wutka.com/jox.html
ÎĵµµØÖ·£º http://www.wutka.com/joxdoc.html
ÏÂÔص ......
XML ×÷ΪÊý¾ÝÔ´µÄʵÀý£¨TESTED£©
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" preinitialize="preInit()" fontSize="12" height="500">
<mx:Script>
  ......
ÕâƪÎÄÕ±»×ªÔصĴÎÊý×î¶à£¬Æäʵ´úÂë¼òªµÃÎÒ×Ô¼º¶¼¿´²»ÏÂÈ¥¡£Ö»²»¹ý·¢±íÕâƪÎÄÕÂʱºÜ¶àÈËÐèÒªÕâ¸ö¹¦ÄÜ¡£
Õ⼸Ììд¸öÊý¾Ý¿â²éѯ·ÖÎöÆ÷£¬ÒªÓõ½XML¼Ç¼Óû§×¢²áµÄÊý¾Ý¿âÁ¬½ÓµØÖ·¡¢¶Ë¿ÚµÈÐÅÏ¢£¬×ʼÏëÓÃjava ......
Ê×ÏÈÎÒÃǸø³öÒ»¶ÎʾÀý³ÌÐò£º
import
java.io.File;
import
java.io.FileWriter;
import
java.util.Iterator;
import
org.dom4j.Document;
import
org.dom4j.DocumentHelper;
import
org.dom4j.Element;
import
org.dom4j.io.OutputFormat;
import
org.dom ......