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

[±¸·Ý]javaÖÐXML½âÎöÀûÆ÷ dom4jµÄʹÓüò½é


ҪʹÓÃdom4j¶ÁдXMLÎĵµ,ÐèÒªÏÈÏÂÔØdom4j°ü,dom4j¹Ù·½ÍøÕ¾ÔÚ http://www.dom4j.org/
Ä¿Ç°×îÐÂdom4j°üÏÂÔصØÖ·: http://nchc.dl.sourceforge.net/sourceforge/dom4j/dom4j-1.6.1.zip
½â¿ªºóÓÐÁ½¸ö°ü,½ö²Ù×÷XMLÎĵµµÄ»°°Ñdom4j-1.6.1.jar¼ÓÈ빤³Ì¾Í¿ÉÒÔÁË,Èç¹ûÐèҪʹÓÃXPathµÄ»°»¹ÐèÒª¼ÓÈë°üjaxen-1.1-beta-7.jar.
ÒÔÏÂÊÇÏà¹Ø²Ù×÷:
Ò»¡¢Document¶ÔÏóÏà¹Ø
1.¶ÁÈ¡XMLÎļþ,»ñµÃdocument¶ÔÏó.
            SAXReader reader = new SAXReader();
            Document document = reader.read(new File("input.xml"));
2.½âÎöXMLÐÎʽµÄÎı¾,µÃµ½document¶ÔÏó.
            String text = "<members></members>";
            Document document = DocumentHelper.parseText(text);
3.Ö÷¶¯´´½¨document¶ÔÏó.
            Document document = DocumentHelper.createDocument();
            Element root = document.addElement("members");// ´´½¨¸ù½Úµã
¶þ¡¢½ÚµãÏà¹Ø
1.»ñÈ¡ÎĵµµÄ¸ù½Úµã.
Element rootElm = document.getRootElement();
2.È¡µÃij½ÚµãµÄµ¥¸ö×Ó½Úµã.
Element memberElm=root.element("member");// "member"ÊǽڵãÃû
3.È¡µÃ½ÚµãµÄÎÄ×Ö
String text=memberElm.getText();
Ò²¿ÉÒÔÓÃ:
String text=root.elementText("name");Õâ¸öÊÇÈ¡µÃ¸ù½ÚµãϵÄname×Ö½ÚµãµÄÎÄ×Ö.
4.È¡µÃij½ÚµãÏÂÃûΪ"member"µÄËùÓÐ×ֽڵ㲢½øÐбéÀú.
List nodes = rootElm.elements("member");
for (Iterator it = nodes.iterator(); it.hasNext();) {
   Element elm = (Element) it.next();
   // do something
}
5.¶Ôij½ÚµãϵÄËùÓÐ×Ó½Úµã½øÐбéÀú.
            for(Iterator it=root.elementIterator();it.hasNext();){
                Element element = (Element) it.next();
    &n


Ïà¹ØÎĵµ£º

JAVAÅжÏ×Ö·û´®ÊÇ·ñΪÊý×Ö

StringתCharacterÊý×飬ÓÃCharacterµÄisDigitºÍisLetterº¯ÊýÈ¥Åжϡ£
public static boolean isNumeric(String str) {
for (int i = str.length(); i = 0;) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
public static boolean isNumeric(String str) {
Pattern patt ......

java ÂÒÂëÎÊÌâ


1¡¢ÖÐÎÄÎÊÌâµÄÀ´Ô´

ÓÉÓÚJava
Óï
ÑÔÄÚ²¿²ÉÓÃUNICODE±àÂ룬ËùÒÔÔÚJAVA
³ÌÐòÔËÐÐʱ£¬¾Í´æÔÚ×ÅÒ»¸ö´ÓUNICODE±àÂëºÍ¶ÔÓ¦µÄ²Ù×÷ϵͳ¼°ä¯ÀÀÆ÷Ö§³ÖµÄ±àÂë¸ñʽ
ת
»»ÊäÈë¡¢Êä³öµÄÎÊÌ⣬Õâ¸öת»»¹ý³ÌÓÐ×ÅһϵÁеIJ½Ö裬Èç¹ûÆäÖÐÈκÎÒ»²½³ö´í£¬ÔòÏÔʾ³öÀ´µÄºº×־ͻá³öÊÇÂÒÂ룬Õâ¾ÍÊÇÎÒÃdz£¼ûµÄJAVA
ÖÐ
ÎÄÎÊÌâ¡£¼¸ºõËùÓÐµÄ ......

¡¾×ª¡¿ JavaÉè¼Æģʽ֮×ÛÊöƪ

JavaÉè¼Æģʽ֮×ÛÊöƪ
http://tech.it168.com/a2009/0223/266/000000266380.shtml
×Ô´ÓJ2EE³öÏÖÒÔÀ´£¬¾Í´ó´ó¼ò»¯ÁËÔÚJavaϵÄÆóÒµ¼¶¿ª·¢¡£µ«ÊÇËæ×ÅJ2EEÔ½À´Ô½ÆÕ±éµØ±»Ó¦Óõ½¸÷¸öÁìÓòÖУ¬¿ª·¢ÕßÃǽ¥½¥Òâʶµ½ÐèÒªÒ»ÖÖ·½·¨À´±ê×¼»¯Ó¦ÓóÌÐòµÄ¿ª·¢¹ý³Ì£¬ËûÃDzÉÓõķ½·¨ÊDZê×¼»¯Ó¦ÓóÌÐòµÄ½á¹¹²ã¡£Ôڽṹ²ãͨ³£·â×°ÁËһЩ¶ÀÁ¢Ó ......

java»Øµ÷»úÖÆ


java»Øµ÷»úÖÆ
 
»Øµ÷¸ÅÄî:
Èí¼þÄ£¿éÖ®¼ä×ÜÊÇ´æÔÚ×ÅÒ»¶¨µÄ½Ó¿Ú£¬´Óµ÷Ó÷½Ê½ÉÏ£¬¿ÉÒÔ°ÑËûÃÇ·ÖΪÈýÀࣺͬ²½µ÷Óᢻص÷ºÍÒì²½µ÷Óá£Í¬²½µ÷ÓÃÊÇÒ»ÖÖ×èÈûʽµ÷Ó㬵÷Ó÷½ÒªµÈ´ý¶Ô·½Ö´ÐÐÍê±Ï²Å·µ»Ø£¬ËüÊÇÒ»ÖÖµ¥Ïòµ÷Ó㻻ص÷ÊÇÒ»ÖÖË«Ïòµ÷ÓÃģʽ£¬Ò²¾ÍÊÇ˵£¬±»µ÷Ó÷½ÔÚ½Ó¿Ú±»µ÷ÓÃʱҲ»áµ÷ÓöԷ½µÄ½Ó¿Ú£»Òì²½µ÷ÓÃÊÇÒ»ÖÖÀàËÆ ......

javaµÄ±àÂëÀ§ÈÅ

   ×î½üдÔ˼۵Äϵͳ,дµÃºÃÀÛ°¡,²»¹ý²î²»¶à½Ó½üÍê³ÉÁË.µ«±àÂëµÄÎÊÌâÒ»Ö±¶¼ÊÇËƶ®·Ç¶®µÄ.
   Ö»ºÃÒ»µãµãÈ¥ËÑË÷javaºÍhtmlµÄ±àÂëÎÊÌâ.ºÃ·³,µ½×îºó,ÎÊÌâÊǽâ¾öÁË,µ«²»ÊÇ×îÍêÕûµÄ´¦Àí·½·¨.Ï£ÍûÒÔºó¿ÉÒÔ´¦ÀíºÃ.
   ÔÚÒ»¸östruts2µÄ·µ»ØÌáʾµÄ×Ö·û´®µ½Ò³ÃæÖÐ.ÎÊÌâ¾ÍÊdzöÔÚÕâ×Ö·û´®ÖÐÓÐÍøÒ³µÄ»»Ð ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ