ͨ¹ýDOM4J½âÎöXMLÎļþС½á
´´½¨XMLÎļþ£º
public boolean createXML(){
try{
Document doc = DocumentHelper.createDocument();
Element root = doc.addElement("root");
Element personNode = root.addElement("person");
Element sonNode = personNode.addElement("fristson");
sonNode.setText("lk1");
Element sonNode2 = personNode.addElement("secandtson");
sonNode2.setText("lk2");
OutputFormat opf = OutputFormat.createPrettyPrint();
opf.setEncoding("GB2312");
XMLWriter xmlw = new XMLWriter(new FileWriter("d:\\myXML.xml"),opf);
xmlw.write(doc);
xmlw.close();
return true;
}catch(Exception e){
System.out.println("error: In create XML");
return false;
}
}
ÒÔÉÏÖ»ÊǸö¼òµ¥µÄ´´½¨ÁËÒ»¸öXMLÎļþÔÚDÅÌÏ£¬Ï±ßÖ÷ÒªÊÇ·ÖÎöXMLÎļþ£¬ÌáÈ¡Ãû×ÖºÍÄÚÈÝ£ºÒÔJAVAÏîÄ¿ÖУ¬¾µäµÄWEB.XMLΪÀý
public boolean updateXML(){
Document doc = null;
try{
SAXReader sr = new SAXReader();
doc = sr.read(new File("d:\\web.xml"));
Element personRoot = doc.getRootElement();
Iterator personNode = personRoot.elementIterator();
while(personNode.hasNext()){
Element sonNode = (Element)personNode.next();
List sonNodes = sonNode.elements();
System.out.println(sonNode.getName());
for(int i = 0 ;i<sonNodes.size() ; i++){
System.out.println(i+":"+((Element)sonNodes.get(i)).getName());
System.out.println(i+":"+((Element)sonNodes.get(i)).getText());
}
Ïà¹ØÎĵµ£º
µ±ÊäÈë ¡·Ê±×Ô¶¯²¹È« µ±ÊäÈ롶/ʱ×Ô¶¯²¹È«
“£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
" File: closetag.vim
" Summary: Functions and mappings to close open HTML/XML tags
" Uses: <C-_> -- close matching open tag
" Author: Steven Mueller <di ......
¶Á£º
//´ò¿ªÄ³Îļþ(¼ÙÉèweb.configÔÚ¸ùĿ¼ÖÐ)
string filename=Server.MapPath("/") + @"WebApplication1\web.config";
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(filename);
//µÃµ½¶¥²ã½ÚµãÁбí
XmlNodeList topM=xmldoc.DocumentElement.ChildNodes;
foreach(XmlElement element in topM)
{
if(ele ......
ÎÊÌâÃèÊö£º
jbossÓ¦Ó÷þÎñÆ÷£¬Ê¹ÓÃspring
ÎÞ·¨Æô¶¯·þÎñ£¬´íÎóÈÕÖ¾£º
[org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@155d3a3] does not
support XML Schema. Are you running on Java 1.4 or below with Apache
Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD ......
·Ü¶·Á˽«½üÒ»¸öÔÂÒÆÖ²gloox¿âµ½brewƽ̨£¬ÔÚxml½âÎöµÄ×¼±¸Õâ±ß»¨Á˲»ÉÙʱ¼ä¡£ÆÚ¼äÒ²ÖØзâ×°Á˱ê×¼¿âµÄstring¡¢map¡¢listÀ࣬ÏÖÔÚ»ØÍ·ÏëÏëÊÕ»ñ»¹ÊÇÂù´óµÄ£¬µ«ÊÇòËÆÊÇÎÞÓõġ£
gloox´Ó0.9°æ±¾¿ªÊ¼¾Íno dependency on iksemel anymore£¬¶øiksemel×î³õÊÇרÃÅΪjabberдµÄxml½âÎöÆ÷£¬Õâô¿´À´£¬¶ÔÕâ¸öʱ¼ä·Ç³£½ôÆȵÄÏîÄ¿À´Ëµ£ ......
½ñÌìÔÚCCÉÏ¿´µ½evangelÔÚÕÐÈË£¬ÉÏÃæдÁËÒ»ÌõÊý¾Ý½âÎö£¬ÎÒÏëÓ¦¸Ã¾ÍÊǶÔXMLµÄ½âÎö°É£¬ÔÝÇÒÕâÑùÀí½âÁË£¬ºÇºÇ¡£ÏÂÎçËÑË÷ÁËÒ»µã¶«Î÷×Ô¼ºÅªÁËÒ»¸öXMLÈ»ºó¶Á¶Á¿´¿´£¬ÏÖÔÚ½ö½öÊǶÁ³öÁËһЩ¶«Î÷£¬Ïȱ£´æ´úÂ룬´ýºóÐø¸üУ¡
Õâ¸öÊÇÎÒ´´½¨µÄxmlÎļþ£¬ÓÃÓÚ²âÊÔÓõģº
<?xml version="1.0" e ......