ÓÃJDOM¶ÁÈ¡XMLÎļþ
Ç°Ì᣺1.JdomµÄ¼Ü¹¹ÒѾµ¼Èë
²½Ö裺
ÓÃJDOM¶ÁÈ¡XMLÎļþÐèÏÈÓÃorg.jdom.input.SAXBuilder¶ÔÏóµÄbuild()·½·¨´´½¨Document¶ÔÏó,
È»ºóÓÃDocumentÀà¡¢ElementÀàµÈµÄ·½·¨¶ÁÈ¡ËùÐèµÄÄÚÈÝ¡£
<?xml version="1.0" encoding="UTF-8"?>
<HD>
<disk name="C">
<capacity>8G</capacity>
<directories>200</directories>
<files>1580</files>
</disk>
<disk name="D">
<capacity>10G</capacity>
<directories>500</directories>
<files>3000</files>
</disk>
</HD>
ÉÏÃæµÄsample.xmlÎĵµ£¬ÃèÊöÁËij̨µçÄÔÖÐÓ²Å̵Ļù±¾ÐÅÏ¢(¸ù½Úµã<HD>´ú±íÓ²ÅÌ£¬<disk>±êÇ©´ú±íÓ²ÅÌ·ÖÇø£¬
´ÓËüµÄnameÊôÐÔ¿ÉÒÔ¿´³öÓÐÁ½¸öÅÌ·ûÃû³ÆΪ"C"ºÍ"D"µÄ·ÖÇø£»Ã¿¸ö·ÖÇø϶¼°üº¬<capacity>,<directories><files>Èý¸ö½Úµã£¬
·Ö±ð´ú±íÁË·ÖÇøµÄ¿Õ¼ä´óС¡¢Ä¿Â¼ÊýÁ¿¡¢Ëùº¬Îļþ¸öÊý)
ÏÂÃæµÄ³ÌÐò¶ÁÈ¡´ËÎļþÖеÄÐÅÏ¢£º
import java.util.*;
import org.jdom.*;
import org.jdom.input.SAXBuilder;
public class Sample1 {
public static void main(String[] args) throws Exception{
SAXBuilder sb=new SAXBuilder();
Document doc=sb.build("sample.xml"); //¹¹ÔìÎĵµ¶ÔÏó
Element root=doc.getRootElement(); //»ñÈ¡¸ùÔªËØ
List list=root.getChildren("disk"); //È¡Ãû×ÖΪdiskµÄËùÓÐÔªËØ
for(int i=0;i<list.size();i++){
Element element=(Element)list.get(i); //»ñÈ¡µÚi¸öÔªËØ
String name=element.getAttributeValue("name"); //»ñÈ¡ÊôÐÔ
String capacity=element.getChildText("capacity"); //È¡disk×ÓÔªËØcapacityµÄÄÚÈÝ
&
Ïà¹ØÎĵµ£º
Êý¾Ý¿âÓ¦ÓÃϵͳ°üÀ¨Êý¾Ý¿â£¬Êý¾Ý¿â¹ÜÀíϵͳ£¬Êý¾Ý¿âÓ¦ÓÃÈý´ó²¿·Ö¡£
ÊÀ½çÉÏ´æÔÚÐí¶àÍêÈ«²»Í¬µÄ¿Í»§Æ½Ì¨£¬ÔÚ²»Í¬Æ½Ì¨¼ä½»»»Êý¾Ý£¬ÐèÒª±£Ö¤Êý¾ÝµÄÍêÕûºÍ·þÎñµÄ¸ßЧ£¬Êý¾Ý¸ñʽµÄת»»ÎÊÌâÍùÍù³ÉΪÖÆÔ¼Web ServiceµÄÆ¿¾±£¬²ÉÓÃXML×÷ΪÊý¾Ý½»»»µÄ±ê×¼£¬¿ÉÒÔʹ¸÷¸öÒ칹ƽ̨ºÍ¸÷ÖÖ¸ñʽµÄÊý¾Ý½øÐÐÊý¾Ý½»»»³ÉΪ¿ÉÄÜ¡£
......
¹ØÓÚ°²×°multiget³öÏÖXML::Parser perl module is required for intltool´íÎóÎÊÌâµÄ½â¾ö ÊÕ²Ø
ÔÚ°²×°Multiget£¬ÔÚconfigureµÄʱºòÌáʾXML::Parser perl module is required for intltool´íÎó¡£¾ßÌå½â¾öµÄ·½·¨ÈçÏ£º #perl -MCPAN -e shell Ö®ºó¸ú¾ÝÌáʾһ²½²½ÍùÏ£¬ÅäÖÃÍêºó»á³öÏÖÒ»¸ö >µÄÃüÁîÌáʾ >install ......
[Bug 230608] missing config.h in latest -14
Ralf Corsepius rc040203 at freenet.de
Tue Mar 6 13:31:13 UTC 2007
Previous message: [Bug 230608] missing config.h in latest -14
Next message: [Bug 230608] missing config.h in latest -14
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] ......
.NET¶Á¡¢Ð´¡¢²é¡¢É¾¡¢¸ÄXMLÎļþ
Ò»¡¢
XML
¼ò½é
XML
¼´¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ£¨
EXtensible Markup Language
£©£¬ÊÇÒ»ÖÖ±ê¼ÇÓïÑÔ£¬ºÜÀàËÆ
HTML
¡£
XML
µÄÉè¼Æ×ÚÖ¼ÊÇ´«ÊäÊý¾Ý£¬¶ø·ÇÏÔʾÊý¾Ý¡£
XML
±êǩûÓб»Ô¤¶¨Ò壬ÐèÒªÓû§¶¨Òå±êÇ©¡£
XML
±»Éè¼ÆΪ¾ßÓÐ×ÔÎÒÃèÊöÐÔ²¢·ûºÏ
W3C
µÄÍƼö± ......