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

ʹÓÃkxml½âÎöxmlÎļþ(¶þ)

Ò». ²»Í¬XML¸ñʽÉϵIJîÒì
<Bil BilID="09120005">
<Product PID="XS000-3">
<Package Needuan="10"/>
<Package Needuan="8"/>
</Product>
</Bil>
 
Óë
<channel>
<title>Meerkat: An Open2 Wire Service</title>
<link>http://meerkat.oreillynet.com</link>
<description>
Meerkat is a Web-based syndicated content reader based on RSS ("Rich Site Summary").
RSS is a fantastic, simple-yet-powerful syndication system rapidly gaining momentum.
</description></channel></rss>  
µÄ²îÒ죺
Ç°ÕßTAGºóÃæÓÐÄÚÈÝ£¬ÀýÈç<Bil ****></Bil>£¬ºóÔòÊÇ<title>text</title>
½áÊøµÄ·½Ê½²»Í¬<package ****/>
¶þ¡¢´¦ÀíÉϵIJîÒì
1. KXMLÔÚ½âÎöʱ£¬½«<Bil ****>ÈÏΪÊÇÒ»¸öSTART_TAG£»Òò´Ë£¬¶Ô
<Bil ****></Bil>µÄ½âÎö£º
½ô½Ó×ÅSTART_TAGµÄ¾ÍÊÇEND_TAG£¬ÖмäûÓÐTEXT£»¶ø
<title>text</title>µÄ½âÊÍÊÇ£º
START_TAG--->TEXT--->END_TAG
ÌáÈ¡<Bil ****>ÖÐ"***"µÄ·½·¨£º
event.getAttributeCount()
event.getAttribute(i)
2.KXML¶Ô<Package Needuan="10"/>µÄ½âÎö£º
START_TAG---->END_TAG
µ±KXMLÓöµ½/>ʱ£¬¾Í»á²úÉúEND_TAG
ÌùÒ»¶Î´úÂ룺
private void parsekXMLItems(XmlParser parser) throws IOException{
// ½ÓÊÕʼþÀàÐÍ
//int eventType = parser.getEventType();
ParseEvent event = parser.read ();
// µ±Ê¼þÀàÐͲ»ÎªÎĵµÄ©Î²Ê±
while (event.getType() != Xml.END_DOCUMENT) { // true
// System.out.println("parsekXMLItems");
switch (event.getType()) {// ÅжÏʼþÀàÐÍ
case Xml.START_TAG:// Ϊ¿ªÊ¼±ê¼Çʱ
System.out.print("<" + event.getName());// Êä³ö¿ªÊ¼±ê¼Ç
frm.append("<" + event.getName());// Êä³ö¿ªÊ¼±ê¼Ç
// µ±ÓÐÊôÐÔʱ£¬Êä³öÊôÐÔ
System.out.println("availableCount:"+event.getAttributeCount());
if (event.getAttributeCount() >= 1)
for (int i = 0; i < event.getAttributeCount(); i++) {


Ïà¹ØÎĵµ£º

JavaµÄXMLÎļþ²Ù×÷Ö®DOMÈëÃÅƪ £¨2£©

ÏÂÃæµÄÄÚÈÝ£¬ÎÒÃǽ«¸ü¶àµÄ¹Ø×¢DOM£¬ÎªDOM×÷Ò»¸ö½ÏΪÏêϸµÄ½âÎö£¬Ê¹ÎÒÃÇʹÓÃÆðÀ´¸üΪµÃÐÄÓ¦ÊÖ¡£
DOMÏê½â
1£®»ù±¾µÄDOM¶ÔÏó
DOMµÄ»ù±¾¶ÔÏóÓÐ5¸ö£ºDocument£¬Node£¬NodeList£¬ElementºÍAttr¡£ÏÂÃæ¾ÍÕâЩ¶ÔÏóµÄ¹¦ÄܺÍʵÏֵķ½·¨×÷Ò»¸ö´óÖµĽéÉÜ¡£
Document¶ÔÏó´ú±íÁËÕû¸öXMLµÄÎĵµ£¬ËùÓÐÆäËüµÄNode£¬¶¼ÒÔÒ»¶¨µÄ˳Ðò°üº ......

ʹÓà domj4 API ´´½¨ÓëÐÞ¸Ä XML Îĵµ

dom4j ÊÇÒ»ÖÖ½âÎö XML ÎĵµµÄ¿ª·ÅÔ´´úÂë XML ¿ò¼Ü¡£±¾ÎĽéÉÜÈçºÎʹÓðüº¬ÔÚ dom4j ÖеĽâÎöÆ÷´´½¨²¢ÐÞ¸Ä XML Îĵµ¡£
dom4j API °üº¬Ò»¸ö½âÎö XML ÎĵµµÄ¹¤¾ß¡£±¾ÎÄÖн«Ê¹ÓÃÕâ¸ö½âÎöÆ÷´´½¨Ò»¸öʾÀý XML Îĵµ¡£Çåµ¥ 1 ÏÔʾÁËÕâ¸öʾÀý XML Îĵµ£¬catalog.xml¡£
Çåµ¥ 1. ʾÀý XML Îĵµ£¨catalog.xml£©
<?xml version=" ......

JavaÓëXMLÁªºÏ±à³ÌÖ®DOMƪ

DOM³õ²½
DOMÊÇDocument Object ModelµÄËõд£¬¼´Îĵµ¶ÔÏóÄ£ÐÍ¡£Ç°Ãæ˵¹ý£¬XML½«Êý¾Ý×é֯Ϊһ¿ÅÊ÷£¬ËùÒÔDOM¾ÍÊǶÔÕâ¿ÅÊ÷µÄÒ»¸ö¶ÔÏóÃèÐð¡£Í¨Ë×µÄ˵£¬¾ÍÊÇͨ¹ý½âÎöXMLÎĵµ£¬ÎªXMLÎĵµÔÚÂß¼­ÉϽ¨Á¢Ò»¸öÊ÷Ä£ÐÍ£¬Ê÷µÄ½ÚµãÊÇÒ»¸ö¸ö¶ÔÏó¡£ÎÒÃÇͨ¹ý´æÈ¡ÕâЩ¶ÔÏó¾ÍÄܹ»´æÈ¡XMLÎĵµµÄÄÚÈÝ¡£
ÏÂÃæÎÒÃÇÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£¬¿´¿´ÔÚDOMÖ ......

ʹÓÃkxml½âÎöxmlÎļþ(Ò»)

Õâ¸öÊDzÎÕÕibmÍøÕ¾ÉϵÄÎÄÕÂ×öµÄ¡£
xmlÔ´Îļþ£º
<?xml version="1.0"?>
<!DOCTYPE rss PUBLIC
"-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd"
>
<rss version="0.91">
<channel>
<title>Meerkat: An Open2 Wire Servic ......

ThroughoutCMS¼¼Êõ¹²ÏíϵÁУ¨2£©£ºXML·ÃÎÊÀà

     ÉϴΰÑÊý¾Ý¿â·ÃÎÊÀ๲Ïí³öÀ´ÁË£¬¼¸¸öͬÊÂÍøÉϸп®ÁËÒ»·¬£¬ÕæµÄûÓÐÏëµ½ÎÒ»¹±£Áô5ÄêÇ°µÄ´úÂ룬ÎÒ˵£¬´úÂë±¾À´¾ÍÊÇÓ¦¸Ã±»ÔĶÁºÍÑо¿µÄ£¬´úÂëͬÑù¾ßÓÐ˼ÏëºÍÇé½Ú£¬Õâ¾ÍÊÇÔÚÒ»Çî¶þ°×µÄÇé¿öϵÄÀúÊ·ºÍ¹ì¼£¡£ÅäÖùÜÀíͬÑùÒ²ÊÇһλ¾¡Ö°µÄÊ·¹Ù¡£
     ×ܽáһϣ¬Éϴθø³öµÄ´úÂë ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ