JDOMÉú³ÉXMLÎĵµ
Ê×ÏÈÏÂÔØJDOM.JAR¼ÓÈëµÄclasspathÖÐ
package com.test.search;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
public class ToXML {
public void BuildXMLDoc(List<SearchBean> list) throws IOException, JDOMException {
//´´½¨¸ú½Úµã
Element root=new Element("search");
//½«¸ú½ÚµãÌí¼Óµ½ÎĵµÖÐ
Document document=new Document(root);
for (int i = 0; i < list.size(); i++) {
SearchBean bean=list.get(i);
Element element=new Element("object");
element.addContent(new Element("URL").setText(bean.getUrl()));
element.addContent(new Element("TITLE").setText(bean.getTitle()));
element.addContent(new Element("DESCRIBE").setText(bean.getDiscribe()));
element.addContent(new Element("INFO").setText(bean.getInfo()));
root.addContent(element);
}
XMLOutputter out=new XMLOutputter();
out.output(document, new FileOutputStream("search.xml"));
}
/*public static void main(String[] args) {
ToXML toXML=new ToXML();
}*/
}
Éú³ÉÍê³É£¬Ö»ÊÇÉú³ÉµÄxmlÎĵµµÄ½ÚµãÓеãÂÒ£¬²»ÊÇÊ÷Ð͵ġ£
Ïà¹ØÎĵµ£º
<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the ......
ÔÚjavaÓ¦Óÿª·¢ÖÐÎÒÃǺÍxml´ò½»µÀµÃ»ú»á̫ƽ·²ÁË£¬Ò»°ãÇé¿öÏÂÎÒ¿´»áÓÃJDOM»òÊÇDOM4jÀ´½âÎöÎÒÃǵÃXMLÎļþ£¬ÏÂÃæÊÇÒ»¸öDom4j½âÎöxmlÎļþµÃÀý×Ó£¬ÆäÖаüÀ¨Á˶ÔxmlÎļþµÃȡֵ¡¢¸³Öµ¡¢ÌáÈ¡½Úµã¡¢½ÚµãµÃ±éÀúµÈ¡£
SAXReader reader =
new
SAXReader();
Document doc = reader.read(...); &nb ......
¿ìÒݱ¨±íÓÐ×ÅÇ¿´óµÄÊä³ö¹¦ÄÜ£¬¿ÉÒÔÖ±½Ó°Ñweb±¨±íµ¼³öΪExcel¡¢Word¡¢Pdf¡¢TxtµÈÎļþÐÎʽ¡£µ«ÊÇһЩweb±¨±íÓû§Ï£Íû¿ÉÒÔ½«±¨±íµ¼³öµ½XMLÎļþÖÐÒÔ±ã¶ÔÊý¾Ý½øÐзÖÎöÓë½âÎö£¬ÕâÑù¾ÍÐèÒªÎÒÃÇÓÃÒ»Ð©ÌØÊâµÄ·½·¨È¥ÊµÏÖÁË¡£
ʵÏÖ˼·
£ºµ¼³öXML¹¦ÄܵĿÉÒÔͨ¹ý½«¼ÆËãºÃµÄIReport¶ÔÏ󴫵ݸø¿ìÒÝÌṩµÄcom.runqian.report4.view.xml ......
jdom¶ÔxmlÎļþµÄ¶Áд²Ù×÷
1. ¶ÁÈ¡XMLÎļþJavaÔ´´úÂ룺
1) xmlÎļþ£º
<?xml version="1.0" encoding="gb2312"?>
<messages>
<message id="1">
< ......
XML DTD ÈëÃÅ(2009-12-14 09:08:49)
±êÇ©£ºÔÓ̸
DTDʵ¼ÊÉÏ¿ÉÒÔ¿´×÷Ò»¸ö»ò¶à¸öXMLÎļþµÄÄ£°å£¬ÕâЩXMLÎļþÖеÄÔªËØ¡¢ÔªËصÄÊôÐÔ¡¢ÔªËصÄÅÅÁз½Ê½/˳Ðò¡¢ÔªËØÄܹ»°üº¬µÄÄÚÈݵȣ¬¶¼±ØÐë·ûºÏDTDÖе͍Òå¡£XMLÎļþÖеÄÔªËØ£¬¼´ÎÒÃÇËù´´½¨µÄ±ê¼Ç£¬ÊǸù¾ÝÎÒÃÇÓ ......