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

ÓÃ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µÄÄÚÈÝ
    &


Ïà¹ØÎĵµ£º

XML ³£Ó÷½·¨¼¯

ÏÂÃæµÄ±í¸ñÁгöÁË°üº¬ÔÚDOM Level 1Öеķ½·¨£¬²¢Áгö²»Í¬µÄä¯ÀÀÆ÷ÊÇ·ñÖ§³ÖÏî¡£
·½    ·¨
Ãè    Êö
IE
MOZ
OP
SAF
createAttribute
(name
)
Óøø¶¨Ãû³Æname
´´½¨ÌØÐÔ½Úµã
×
×
×
£­
createCDATASection
(text
)
Óðüº¬Îı¾
text
µÄÎı¾×Ó½Úµã
´´½ ......

ÔÚ.net µ±ÖÐÈçºÎXMLÐòÁл¯Ò»¸öCollection

CollectionÖ÷ÒªÊÇÖ¸ÏñArray, ArrayList, List, Dictionary, HashTableÕâЩÊý¾ÝÀàÐÍ£¬´ó¼ÒƽʱÓõĺܶࡣÈç¹ûÒ»¸öÀàÖÐÓÐÒ»¸öCollectionÀàÐ͵ijÉÔ±£¬ÔÚ¶ÔÕâ¸öÀà½øÐÐXMLÐòÁл¯µÄʱºò£¬Ó¦¸ÃÈçºÎ´¦Àí£¿Ó¦¸Ã˵ÔÚ.netµ±ÖÐÕâÊDZȽϼòµ¥µÄ£¬Ö»Òª½¨Á¢Ò»¸öXmlSerializerÀà¾Í¿ÉÒÔ°ïÄã×Ô¶¯¸ã¶¨£¬²»¹ýÓеÄʱºòÄã¿ÉÄÜÐèÒª¶Ô×Ô¶¯µÄÐòÁл¯¹ý³ ......

½»»»Êý¾Ýѧϰһ£º½«xmlÎı¾¶ÁÈ¡µ½DataSet²¢ÏÔʾ

//xmlÎĵµÄÚÈÝ
<?xml version = "1.0" encoding="gb2312" standalone="yes"?>
<VFPData>
 <company>
  <companyno>100</companyno>
  <companyname>ÉϺ£</companyname>
  <ceoname>³ÂËÄ</ceoname>
  <ceoma ......

Symbianѧϰ±Ê¼Ç(15) ½âÎöXMLÎļþ(ÉÏ)

ÊÕ²Ø
ÎÒÔøÔÚÇ°Ãæ½éÉܹýÒ»¸ö¿ÉÓÃÓÚBREW»·¾³ÏµÄXML Parser£¬½ñÌìÏë·ÖÏíµÄÊÇÈçºÎÔÚSymbianƽ̨ÉϽâÎöXMLÎļþ£¬²»ÐèÒªµÚÈý·½µÄ¶«Î÷£¬SymbianÒѾ­ÎªÎÒÃÇÌṩÁËÕâ¸öÀàCParser¡£
ÍøÉÏÒ²ÓÐÕâ·½ÃæµÄ×ÊÁÏ£¬½¨Òé²Î¿¼£º
http://wiki.forum.nokia.com/index.php/How_to_parse_XML_file_using_CParser_class
²»¹ý£¬Òª×¢ÒâµÄÊÇSymbia ......

AndroidÅÄÕÕÉÏ´«³ÌÐòµÄxmlÅäÖÃÎļþ

1. login_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_logo"
>
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ