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

ʹÓÃ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 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> 
½âÎöcode£º
public static void traverse( XmlParser parser, String indent ) throws Exception
{
boolean leave = false;
String title = new String();
String desc = new String();
do {
ParseEvent event = parser.read ();
ParseEvent pe;
switch ( event.getType() ) {
// For example, <title>
case Xml.START_TAG:
// see API doc of StartTag for more access methods
// Pick up Title for display
System.out.println("start tag "+event.getName());
if ("title".equals(event.getName()))
{
pe = parser.read();
title = pe.getText();
}
// Pick up description for display
if ("description".equals(event.getName()))
{
pe = parser.read();
desc = pe.getText();
}
textBoxString = title + " " + desc;
traverse( parser, "" ) ; // recursion call for each <tag></tag>
break;
// For example </title?
case Xml.END_TAG:
System.out.println("end tag");
leave = true;
break;
// For example </rss>
case Xml.END_DOCUMENT:
System.out.println("end document");
leave = true;
break;
// For example, the text between tags
case Xml.TEXT:
System.out.println("text");
break;
case Xml.WHITESPACE:
System.out.println("white space");
break;
default:
System.out.println("default");
}
} while( !leave );
t.setString(


Ïà¹ØÎĵµ£º

ģʽºÍxmlѧϰ£¨2£©

Ò»£ºÉè¼Æģʽ²¿·Ö
״̬ģʽ£¨state£©
״̬ģʽÀàËÆÓÚÒ»ÖÖ¼òµ¥µÄ¹¤×÷Á÷£¬ÓÃÀ´°Ñ´óÁ¿µÄÅжϷÖÖ§½øÐвð·Ö£¬¸øÿһÖÖÅжÏÔö¼ÓÒ»¸ö״̬£¬Èç¹û²»Âú×ã¸ÃÅжϿÉÒÔ½øÐÐ״̬ת»»£¬ÖªµÀÓöµ½Âú×ãÌõ¼þΪֹ
ÕâÑù×öµÄºÃ´¦¾ÍÊÇ£¬µ±ÐèÒªÔö¼ÓÅжϵÄʱºò£¬²»ÐèÒª¸Ä±äÒѾ­´æÔڵĴúÂë¡£Ö»ÐèÒªÔö¼ÓÅжϵÄÀ࣬ԭʼÅжÏÀàÖÐÔö¼ÓеÄ״̬ת»»¡£
Ê ......

XmlDocument.LoadXML+ÈçºÎ¹¹Ôìxml×Ö·û´®

http://topic.csdn.net/u/20080905/10/caea1689-4582-417a-8723-d008a3ae1a10.html?550638422
            tringBuilder sb = new StringBuilder();
            sb.Append(" <?xml version=\"1.0\"?> ");
    ......

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

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

Struts 2 ʹÓÃXMLÎļþУÑé½Ì³Ì

Struts 2 ʹÓÃXMLÎļþУÑéÀýÌâ
ÔÚÕâ¸öÀý×ÓÖÐÎÒÃǽ«Á˽⵽ÔõôÑùͨ¹ýXMLÎļþÀ´½øÐÐУÑé¡£XMLУÑéÎļþ±ØÐëÒÔ"¶¯×÷(action)Àà-Validation.xml"µÄÐÎʽÃüÃû¡£ÔÚÕâ¸öÀý×ÓÖУ¬¶¯×÷(action)ÀàÃûÊÇ"Login.java"£¬XMLÎļþÃûÊÇ"Login-Validation.xml"¡£
Login-validation.xmlµÄÎļþÄÚÈÝÈçÏ£º
<!DOCTYPE validators PUBLIC "-//O ......

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

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