Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

DOM4JÉú³ÉXMLÎĵµ


public int createXMLFile(String filename) {
  int returnValue = 0;
  Document document = DocumentHelper.createDocument();    //Éú³ÉDocument£¬ÓÃÓÚ¹ÜÀíXMLÎĵµ
  
  Element booksElement = document.addElement("books");    //Ìí¼Ó¸ù½Úµã
  
  booksElement.addComment("This is a test for dom4j, holen, 2004.9.11");   //Ìí¼Ó×¢ÊÍ
  
  Element bookElement = booksElement.addElement("book");      //ÔÚ¸ú½ÚµãbooksÏÂÌí¼ÓÒ»¸öbook×Ó½Úµã
  
  bookElement.addAttribute("show", "yes");    //ΪbookElementÌí¼ÓÊôÐÔ£¬²¢Öƶ¨ÊôÐÔµÄÖµ
  
  Element titleElement = bookElement.addElement("title");   //ΪbookElement½ÚµãÌí¼ÓÒ»¸ötitle×Ó½Úµã
  
  titleElement.setText("Dom4j Tutorials");      //Ϊtitle×Ó½ÚµãÉèÖÃÎı¾½ÚµãÄÚÈÝ
  
  try {
   XMLWriter writer = new XMLWriter(new FileWriter(new File(filename)));
   
   writer.write(document);  //ÆÕͨ¸ñʽ£¬±È½Ï²»ÃÀ¹Û
      
      OutputFormat format =null;
       
     
//      format=OutputFormat.createPrettyPrint();       //ÃÀ»¯¸ñʽ,¶ÁÈ¡ºóÃÀ»¯ÏÔʾ     
//   writer = new XMLWriter( System.out, format );   
//   writer.write( document );
   
//   format = OutputFormat.createCompactFormat();  //Ëõ¼õ¸ñʽ£¬¶ÁÈ¡ºóËõ¼õÏÔʾ
//   writer = new XMLWriter( System.out, format );
//   writer.write( document );
   
   
   writer.close();
   
   return


Ïà¹ØÎĵµ£º

linq to xml(MOSS GetCurrentUser)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Data;
using System.Dat ......

sql_map_config.xml(SQL Map»·¾³Îļþ)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
 "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
 <!-- ÅäÖúÍÓÅ»¯SQL Map½âÎöʵÀýµÄÉ趨 -->
 <settings cacheModelsEnabled=" ......

xml½âÎö_java

private ClassLoader xmlLoader = Thread.currentThread().getContextClassLoader();
private void parseXML(String resource){
  resource = StringUtils.substring(resource,resource.indexOf(":")+1,resource.length());
  InputStream inputStream =  xmlLoader.getResourceAsStream(resou ......

javaÉú³ÉXMLÎļþ×Ô¶¯»»ÐÐÎÊÌâ

Java codeFormat ft=Format.getRawFormat();
ft.setEncoding("utf-8");
ft.setIndent("    ");//ÉèÖÃËõ½ø
       
XMLOutputter outputter=new XMLOutputter(ft);//ÉèÖÃXML¸ñʽ
Õâλ˵µÄ²»´í£»
ÔÚieÀïÃæ£¬ËüÄܰÑxml×Ô¶¯½âÎö³ÆÊ÷Ðνṹ£¬ËùÒÔ¿´ÆðÀ´Ã»ÎÊÌ⣬ÔÚ¼Çʱ¾ÀïÃæ£¬¾Í²»ÐÐÁ ......

ÔÚXMLÖж¨Òå²Ëµ¥

ºÍAndroid UI layoutÒ»Ñù£¬ÎÒÃÇÒ²¿ÉÒÔÔÚXMLÖж¨ÒåÓ¦ÓóÌÐòµÄ²Ëµ¥¡£Í¨¹ýÔڲ˵¥µÄonCreateOptionsMenu·½·¨ÖÐÅòÕͲ˵¥layout¡£ÕâÑù×ö»áʹÎÒÃǵijÌÐò´úÂë¼òµ¥¶àÁË£¬¶øÇÒ¾¡¿ÉÄܵĽ«¸ü¶àµÄ½çÃæÉè¼Æ²¿·Ö·Åµ½XML£¬±ãÓÚä¯ÀÀ¡£
 
1. ÔÚ¹¤³ÌµÄ/res/Îļþ¼ÐÏ´´½¨menuÎļþ¼Ð£¬ÓÃÀ´±£´æÄãΪӦÓóÌÐò¶¨ÒåµÄ²Ëµ¥XMLÎļþ¡£
Ôڲ˵¥XML ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ